LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   Print a file if it exists and rename it at the same time. (https://www.linuxquestions.org/questions/linux-enterprise-47/print-a-file-if-it-exists-and-rename-it-at-the-same-time-348755/)

bhar0761 08-01-2005 02:13 AM

Print a file if it exists and rename it at the same time.
 
I would like to write a script to print files in a directory if they exist and then rename them at the same time. This script will of course loop forever because new files are created all the time and i don't want to keep printing them.

One option i did look at would be to mv the files right after they print but if new files are created before they are printed, the move command will move them before they print.

B

Jerre Cope 08-01-2005 11:51 PM

bash:

while true
do
for i in `ls | grep -v printed`
do
lp $i
mv $i $i_printed
done
sleep 5
done

Jerre Cope 08-01-2005 11:51 PM

The indenting got whacked when I posted...sorry.


All times are GMT -5. The time now is 11:02 AM.