[Solved] Find Files Created Recently and Print

Hi,

I'm looking to create a script which will find all the files created in the last 24h in a directory starting with a few different letters and send them to the printer. This would be run through the cron each morning to print the last 24 hours files.

I have started with this to find all the files beginning with FILE in the /the/data directory from the last 24 hours.

find /the/data -name FILE* -mtime 0

However, how would I then print each of these files individually? Should I build some sort of array and run this in a loop -

lp -d printer $file

Also, the file can have a few names, so I was just going to replicate this section of the script for each FILE* name, but if there is a neater way to return files from the find command I suppose that would be better. Maybe the find could be changed to something like,

find /the/data -name "FILE*" -o -name "AUDIT*" -o -name "LOG*" -mtime 0

Not sure of the best way to do this :slight_smile:

Thanks in advance!

find /the/data -name "FILE*" -o -name "AUDIT*" -o -name "LOG*" -mtime 0 | while read filename; do lp -d printer $filename; done
1 Like

Perfect, thanks.