Results 1 to 5 of 5
Hi!
I've created a bash file to move all files that end witha tilde (~) to my /home/user/.Trash directory where they are stored so I can delete or restore them ...
- 07-23-2009 #1
Multiple Commands Issue
Hi!
I've created a bash file to move all files that end witha tilde (~) to my /home/user/.Trash directory where they are stored so I can delete or restore them at a later time.
I want to list the files that have changes within the last hour. I'm able to do that but if none have been changes, I want to print out a message stating that none of the file have been changed. I've tried multiple commands but I'm not able to print out the message.
Here's what I have:
# Cleanup bash file cleanup /home/user & /var/www directories
# and sends error messages to /dev/null directory.
clear
find /home/user -iname 'cleanup~' -type f -exec mv '{}' /home/user/.Trash \; 2>/dev/null
find /home/user -iname '*.*~' -type f -exec mv '{}' /home/user/.Trash \; 2>/dev/null
find /var/www -iname '*.*~' -type f -exec mv '{}' /home/user/.Trash \;
echo "All files cleaned up."
echo "-----------------------------------------------------------------------------"
echo "Last files cleaned up:"
find /home/user/.Trash -iname '*~' -mmin -60 || echo "No new files added." -exec ls -t '{}' \; 2>/dev/null
echo "-----------------------------------------------------------------------------"
Can someone please tell me if this is possible or what I'm doing wrong?
- 07-23-2009 #2Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
Try this:
Code:find /home/user/.Trash -iname '*~' -mmin -60 | tee /tmp/tmp.tmp ; if [ ! -s /tmp/tmp.tmp ]; then echo 'No new files added'; fi; rm -f /tmp/tmp.tmp
- 07-23-2009 #3
Not working the way I'd like...
i tried the code. Creates a tmp.tmp file in the /home/user/.Trash directory. That's all...
- 07-23-2009 #4Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
Since tmp.tmp wasn't created in the /tmp directory shows that you didn't copy the command correctly. Did you get all of it? Here's the command again without it being in a code block:
find /home/user/.Trash -iname '*~' -mmin -60 | tee /tmp/tmp.tmp ; if [ ! -s /tmp/tmp.tmp ]; then echo 'No new files added'; fi; rm -f /tmp/tmp.tmp
- 07-23-2009 #5
I got it all that time. Works now. Thanks!


Reply With Quote
