0

I have tons of *.csv measurement files with following header:

Start time: Thu Oct 09 15:46:16 CST 2014 
Trend type: Average Wavelength over [259.09, 259.09] 
Trend offset: None 
>>>>>Begin Strip Chart Data<<<<<
Date    Elapsed Time    Absorbance(Absorbance)

How can I change this with command-line in the whole directory to following header:

Date    ElapsedTime Absorbance

Cheers,

Hans

1
  • To clarify: you want to strip off the first 4 lines of each file? Or all lines before "Date Elapsed Time Absorbance(Absorbance)"?
    – nohillside
    Commented Oct 9, 2014 at 8:50

1 Answer 1

1

This will remove first four lines form csv files and remove "(Absorbance)" part from them:

find . -name  "*\.csv" -exec \
    bash -c "tail -n +5 {} |
                 sed 's/Absorbance(Absorbance)/Absorbance/' |
                 sed 's/Elapsed Time/ElapsedTime/' > {}.bak |
                 mv {}.bak {}" \;
3
  • Thanks, you saved me at least one day of copy and paste!! The only thing left is to remove the space in "Elapsed Time" to get "ElapsedTime". I tried it with sed but the result was a empty file (because I have no idea of apple skript ;)
    – Hans
    Commented Oct 9, 2014 at 9:54
  • I've eddited my answer. But If You have already run this command, remove tail because You'll lose first 4 lines in every csv file. Commented Oct 9, 2014 at 10:38
  • 1
    @Hans note this is not AppleScript but Unix shell script
    – mmmmmm
    Commented Oct 9, 2014 at 14:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .