Page 167 - DCAP106_OPERATING_SYSTEM_TOOLS
P. 167
Operating System Tools
Notes A character sequence ‘{}’ represents the file found by the find command. The command given to
the -exec option is executed and ‘{}’ is substituted with the filename.
A character sequence \; ends the command in the -exec clause.
$ find /etc -type f -mtime -7 -exec ls -l ‘{}’ \;
On the Internet, you’ll also find the following construction:
$ find /etc -type f -mtime -7 | xargs ls -l ‘{}’
This gives the same result, however its behaviour is slightly different.
When we use -exec, the find command executes the command for each file it encounters. The
xargs construction will attempt to execute the command as little as possible, based on the
argument limits.
Example: If the find command returns 10000 files, the command given to -exec is executed
10000 times, once for every file.
With xargs, the command might be executed only a few dozen times. This is possible because
xargs appends multiple files for a single command as it assumes that the command given can
cope with multiple files.
Example: Run for find -exec:
ls -l file1
ls -l file2
...
ls -l file10000
Example run for xargs:
ls -l file1 file2 ... file4210
ls -l file4211 file4212 ... file9172
ls -l file9173 file9174 ... file10000
9.3.3 GNOME
GNOME Search Tool is a utility which is used for finding files on your system. To do a basic
search, type a filename or a partial filename, with or without wildcards.
Basically, the Gnome Search Tool is a GUI version of locate and find. When doing a basic search,
the locate command is used first by default. Then the slower but more thorough find command
is used.
This program can be started by typing the following command at shell prompt:
$ gnome-search-tool &
On the other hand, you can find the Gnome Search Tool by going to Places > Search For Files
The case sensitivity of the search relies on your operating system.
Example: On Linux, the find, grep, and locate commands support the -i option, so all
searches are case-insensitive.
160 LOVELY PROFESSIONAL UNIVERSITY