
On 15 October 2010 09:00, Peter Reutemann <fracpete(a)waikato.ac.nz> wrote:
I was wondering if someone could help with the output of find in a simple bash script.
I need to output the file create date and time from the following script. The purpose of this script is to find an order number and check if that has been received by the system. If it does then it needs to return the date and time the file was archived if it doesn't then it shows a message saying that it cant find it in the archive.
find /home/archive/* -mtime -90 |\ xargs grep -l $searchstring
previously I was piping the output of the grep command to ls -lath and that was sufficient but there are too may files in the directory now that it dies.
Not sure whether this works on such large amounts of files... Instead of piping the filenames into "xargs/grep", just use the "-exec" option of the "find" command to execute "grep". Also, read line by line of the file matches from stdin when using "ls -lath".
That will spawn a new grep command for every file. The original command using xargs is much more efficient.