当前位置: 动力学知识库 > 问答 > 编程问答 >

csv - How to schedule a basic unix command using sed

问题描述:

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.

网友答案:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: