Uroxatral 10mg pills $124.00 Like many Linux and UNIX commands, uroxatral 10mg pills $124.00 the find command supports a long list of options. Uroxatral 10mg pills $124.00 I covered several of the options in a previous article but there are even more useful options. Uroxatral 10mg pills $124.00 Here are some of them:

Uroxatral 10mg pills $124.00 Doing things with what we find

Uroxatral 10mg pills $124.00 The –exec option gives find the powerful ability to execute commands on the files found. Uroxatral 10mg pills $124.00 The syntax is a little tricky but an example is usually all it takes to get it right.

Uroxatral 10mg pills $124.00 Before using the -exec option, uroxatral 10mg pills $124.00 especially with a powerful command like rm I recommend performing the same find without the –exec. Uroxatral 10mg pills $124.00 By doing this you will see exactly which files you will be affecting when you run the final command.

Uroxatral 10mg pills $124.00 The following is a practical example that finds files less than three days old with the .txt extension and deletes them.

Uroxatral 10mg pills $124.00 Finding .txt Files < 3 Days Old and Delete Them

Uroxatral 10mg pills $124.00 $ find . Uroxatral 10mg pills $124.00 -name '*.txt' -mtime -3 -exec rm {} \;
$ ls –lt
total 8
-rw-r--r-- 1 tclark authors 2229 Jan 13 21:35 declaration.txt
-rw-rw-r-- 1 tclark presidents 1310 Jan 13 17:48 gettysburg.txt

Uroxatral 10mg pills $124.00 The –exec option allows you to put any command after it. Uroxatral 10mg pills $124.00 Here we have used rm but it is often useful to use this option with cp or chmod. Uroxatral 10mg pills $124.00 Within the command to be run there must be two curly brackets {}. Uroxatral 10mg pills $124.00 find will execute the command for each file it finds substituting the file name (and path) where the curly brackets are. Uroxatral 10mg pills $124.00 Finally the end of the –exec option is signaled by an escaped semicolon (\;). Uroxatral 10mg pills $124.00 The –exec option should always be the last option given in a find command.

Uroxatral 10mg pills $124.00 The find command is great for finding files and directories but next we’ll look at some options for finding other things on the system.

Uroxatral 10mg pills $124.00 Dealing with “Permission denied” in find

Uroxatral 10mg pills $124.00 If you use find a lot (and you probably will) you will sometimes run into the problem where you get just pages and pages of output like this:

Uroxatral 10mg pills $124.00 $ find / -name '*.txt'
find: /var/lib/dav: Permission denied
find: /var/lib/nfs/statd: Permission denied
find: /var/lib/dhcpv6: Permission denied
find: /var/lib/slocate: Permission denied
find: /var/lib/xdm/authdir: Permission denied
find: /var/lib/php/session: Permission denied
find: /var/log/samba: Permission denied
find: /var/log/ppp: Permission denied
find: /var/log/audit: Permission denied
find: /var/log/squid: Permission denied

Uroxatral 10mg pills $124.00 This is find telling you there are certain directories you don’t have permissions to search. Uroxatral 10mg pills $124.00 This can make it very difficult to find the useful output of the find as it can be mixed in with the permissions errors.

Uroxatral 10mg pills $124.00 To ignore these (and any other) errors and just get the results of what you can find we can use a special redirect at the end of the command. Uroxatral 10mg pills $124.00 Redirecting output will be covered in more detail in the chapter on shell scripting, uroxatral 10mg pills $124.00 but suffice it to say that in this command 2>/dev/null is redirecting the error output to nowhere.

Uroxatral 10mg pills $124.00 $ find / -name '*.txt' 2>/dev/null

Uroxatral 10mg pills $124.00 While it would not be a good idea to redirect the error output all the time (usually you want to know when something has gone wrong) in this case of the find command it can be very useful.

Easy Linux CommandsFor more tips like this check out my book Easy Linux Commands, uroxatral 10mg pills $124.00 only $19.95 from Rampant TechPress.

Buy it now!

Uroxatral 10mg pills $124.00

Uroxatral 10mg pills $124.00 find, uroxatral 10mg pills $124.00 search, uroxatral 10mg pills $124.00 unix, uroxatral 10mg pills $124.00 linux, uroxatral 10mg pills $124.00 system administration, uroxatral 10mg pills $124.00 sysadmin

Average Rating: 4.7 out of 5 based on 246 user reviews.