The following command will create a pdf file under ~/PDF/:
enscript -B -P PDF bloom.c
I want to move the output pdf file here
mv "`ls -dtr1 ~/PDF/* | tail -1`" .
But I can't run the mv command immedately follow the enscript command, because enscript sends the input file to the printer PDF, and returns immediately before the printer finishes creating a pdf file.
A very bad solution is to insert the following command between the two commands
sleep 5
It is bad because I don't know how long I shall wait.
Note that I know there is other better way to do the same thing without having to run the mv command after enscript, but I just wonder if there is any way to make enscript block till the printer finishes its job? I remember having similar thoughts for other commands besidesenscript.
I am assuming that enscript doesn't provide such an option, so would be interested in whether bash or other program can make that happen. Signal handling might be a solution, but I don't know which signal to catch.