3

I'm actually looking for a bash script who monitor a file, execute each new line in the file and then remove the line. When all the file is processed, the script mush wait for new lines.

I searched for any answers but barely found anything more than reading each line in a file.

By the way, is bash efficient at a task like this or should I build a little C program to do this?

0

The following does everything you ask except for removing the lines from the file:

$ ./script && tail -n0 -f script | while read line; do eval "${line}"; done;

First, just execute the file and then abusing tail and eval you can quite easily approximate the behavior you desire.

  • Thanks, since the loop start at the end of the file I can do what I want without removing lines. So this do exactly what I need :) – José Mélançon Feb 7 '12 at 5:43
0

If removing the line is not a must, you can also try:

 tail -f filename | parallel eval "{}"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.