2

Apreciate any help and excuse me if my terminology is incorrect.

sed -i '1,6d;$ d' *.csv

This unix command, run on cygwin, will go through all the files in the directory that end with .csv.
For each file it deletes the 1st 6 rows and the last row and that's the returned file.

My question is how do I go about scheduling this so that it is run on a certain directory periodically?

Note: I have a fair idea around basic unix commands. Also, I currently do some scheduling, using task scheduler in windows XP, using vbs to work on some excel files.

HattrickNZ
  • 4,373
  • 15
  • 54
  • 98
  • @Andrew Barber - how can I edit it so that it is not off topic? tks – HattrickNZ Jan 21 '14 at 04:33
  • What's the point to hold this question, looks fine for me. I don't think this topic will go to `super User` – BMW Jan 21 '14 at 06:08
  • repeat to remove 7 lines in csv file by schedule job? That means the file will be cleaned soon or later. Did you notice this? – BMW Jan 22 '14 at 02:53
  • @BMW this will only ever be run once on the file, and the file will get updated and then the script/formatting will have to be applied to it again.hope that makes sense. – HattrickNZ Jan 22 '14 at 21:55

1 Answers1

1

You can run cron on windows which allows scheduling bash (cygwin) scripts too. Here is the related Stackoverflow discussion.

If you don't want this, you can create a .bat batch file with contents like

chdir C:\where\you\want\to\run\this\script
C:\Cygwin\Or_where\you\installed\bin\sed.exe -i '1,6d;$ d' *.csv

And run this batch file from the Windows scheduler.

Then there is the windows version of the at command which works a bit like the *nix cron. Here is an explanation.

Community
  • 1
  • 1
Zsolt Botykai
  • 50,406
  • 14
  • 85
  • 110