capturing output from "find"
i'm trying to capture the output of a find command i'm using to see which files are beyond a certain age. it will be used to report on which files i'll be deleting. examples script:
find /home/lacey/test/cleanup/ -cmin -15 -type f -print find /home/lacey/test/cleanup/ -cmin -15 -type f -exec rm -r {} \; the first command prints out what files are older than 15 min. the second command deletes them. i want a way to save the output from the first command, and then e-mail myself the list generated from the first command. this will then e-mail me whenever a file is deleted. any help on how to do this...or even if you know a better way i would appreciate. thanks. |
To save running 2 find commands try:
Code:
#!/bin/bash |
[root@localhost test]# ./test2.sh
/home/lacey/test/cleanup/test8 /home/lacey/test/cleanup/test9 [root@localhost test]# log... User unknown ...... this is what happens when i run the above script. i type "./test2.sh" and this is what happens. it just sits there and waits for me to hit return or something. anyway it is echoing correctly as you can see and it also e-mails me correclty i just don't know why it is doing the log....user unknown and then just hanging there. maybe it is b/c of IFS....which i have no background with and have no idea what it is doing. or is it from the log command at the end of cat command that is pipped to mail.? |
I think it is seeing log as an extra argument try replacing the line with:
cat /tmp/cleanup.log | mail root -s "Cleanup log" |
All times are GMT -5. The time now is 04:56 PM. |