Quote:
Originally Posted by jschiwal
I always use '{}' \; in the -exec argument.
Also, for files and empty directories you can use "-delete" instead of "-exec rm '{}' \;" or "-exec rmdir '{}' \;"
In the line you quoted, you could use:
find . -name test1 -ls
If someone were to delete files I saved at work that were 30 days old, I would be missing things I needed. Such as saved firmware for devices or documents I saved for reference, old backup catalogs, etc.
|
I am very flattered that the forum moderator has responded to my question! Thanks again.
Well, I'm back after trying EVERYTHING that everyone suggested so far with no success except an expansion of my learning process, which is also good. By the way, if I could use the -atime argument with this FIND command on my Thecus I would, but this FIND command does not accept many of the standard arguments. I may learn enough about the Linux in the Thecus to install a better FIND command if that's the problem.
Firstly one poster suggested that I forgot the files argument, which could be expressed by
find .
I am under the impression that the find command will operate on all directories within and below the current directory so the files argument is optional if you are located where you are. And that appears to be working because I assume that because simpler find commands without the attempts to delete do the job for me. Nevertheless, in my further experiments, the presence or absence of the dot after the find did not appear to help me. Again, I am using the -mtime argument instead of the -atime argument only because the FIND command in this Thecus does not seem to recognize it. The following is a transcript of my recent attempts, from a simple find to a more complex set of attempts. As you can see, in many cases the FIND command in my Thecus Linux simply does not recognize the arguments that you are suggesting to me. I'm hoping it's just a syntax error.
FIND WITH SIMPLE -MTIME ARGUMENT PRODUCES SUCCESSFUL RESULT (CHOOSING 90 DAYS FOR THE MOMENT):
root@127.0.0.1:/raid/data/incremental-backup# find -mtime +90
./Thecus Documents/temp bob's transfer folder/Hamilton order.bmp
./Thecus Documents/temp bob's transfer folder/Sequoia/Crash log.txt
./Thecus Documents/Projects DD/Godaddy-Email-Network-Web/Dreamhost newly formatted.txt
root@127.0.0.1:/raid/data/incremental-backup#
I'M SURE YOU WILL NOTICE THAT OF THE THREE FILES FOUND, THEY ALL HAVE SPACES IN THEIR FILE NAMES.
ATTEMPT USING THE -DELETE ARGUMENT, -DELETE IS APPARENTLY NOT RECOGNIZED:
root@127.0.0.1:/raid/data/incremental-backup# find . -mtime +90 -delete
BusyBox v1.1.0 (2009.03.26-08:00+0000) multi-call binary
Usage: find [PATH...] [EXPRESSION]
Search for files in a directory hierarchy. The default PATH is
the current directory; default EXPRESSION is '-print'
EXPRESSION may consist of:
-follow Dereference symbolic links
-name PATTERN File name (leading directories removed) matches PATTERN
-print Print (default and assumed)
-type X Filetype matches X (where X is one of: f,d,l,b,c,...)
-perm PERMS Permissions match any of (+NNN); all of (-NNN);
or exactly (NNN)
-mtime TIME Modified time is greater than (+N); less than (-N);
or exactly (N) days
-newer FILE Modified time is more recent than FILE's
-inum N File has inode number N
-exec CMD Execute CMD with all instances of {} replaced by the
files matching EXPRESSION
ATTEMPT USING THE -EXEC ARGUMENT PRODUCES ERRORS RELATED TO SPACES WITHIN THE CHOSEN FILE NAMES. (THIS LED ME TO MY OTHER POST WHICH ATTEMPTED THE ALTERNATE FORM OF EXEC TERMINATED WITH A + SIGN, AND SOME VERY COMPLICATED SYNTAX THAT I HAVE NOT CONQUERED):
root@127.0.0.1:/raid/data/incremental-backup# find . -mtime +90 -exec rm '{}' \;
sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
rm: cannot remove `./Thecus': No such file or directory
rm: cannot remove `Documents/Projects': No such file or directory
rm: cannot remove `DD/Godaddy-Email-Network-Web/Dreamhost': No such file or directory
rm: cannot remove `newly': No such file or directory
rm: cannot remove `formatted.txt': No such file or directory
root@127.0.0.1:/raid/data/incremental-backup#
SO, THAT'S WHERE I AM RIGHT NOW. YES, I AM A NEWBIE AT THIS. :-(.