I have a bash script that takes 3 arguments:
$ do_something foo bar baz
and a file with several lines, each with different 3 args.
I want to execute the script as a cronjob, and each time it's called it should call
do_something on a line in that file, passing it the three arguments on that line. Next time it's called it should run the next line, so it will take
n calls to
do_something for it to process
n lines. If it processed the last line of the file, it should start over at the beginning next time.
My solution is to remove the processed line from the head of the file each time and append it to tail, but it seems me too cumbersome having all these disk writes just to remember a position. I could have another file around with a pointer to last line, but three files for a simple task is not that smart. Is there a better solution?