Right this is quite a long one,
I have a script which complies all listed stats files into one file and emails it out,
However this has to be run manually and i would like it to run automatically,
I have a list of files eg
sa17
sa18
sa19
sa20
sa21
one file for each of last weeks working days,
howver I need them in this format
17 18 19 20 21
And then I need to use them as the input to a script.
any info is helpful
right Im thinking an easier way is run a find to get all the sa files written last week and then I want to run my sar.sh script on each of these. so at the momment i have
find /var/adm/sa -type f -mtime +2 | grep sa[1-9] | while read f;do sar.sh ;done
is this ok as at the minute it doesnt seem to be working
Well, as we don't have an idea how your directory structure looks like, we can't tell how many files will be found below that starting dir. You may want to add the -prune action. Also, the -mtime +2 (older than now - (48h+)) is depending on the time you issue the command; it will yield different results on Monday or on Tuesday, and if issued at 10:00h in the morning or later at night.
The grep will grep filenames sa1 till sa9, but not sa10, sa15, or sa17. Use [1-9][1-9] for a two digit wildcard.
And, finally, you read filenames in the while loop, but you don't use them as a parameter for your sar.sh script; unless you are using the f variable in the script, all the filename a thrown to the bin, making the earlier commands redundant.
I have sorted this out using the -exec function of the find command,
I needed to run the sar -uf command on each individual file in the /var/adm/sa directory
and using grep sa[1-9] does grep for two digits or more as the [1-9] for grep is a wildcard for all numbers not just the ones listed