Installation guide

C H A P T E R 5 Using the VMware Service Console
199
Finding and Viewing Files
Command Example and Explanation
cat Concatenate the contents of files and display the content on the screen.
cat /proc/vmware/mem
Display the contents of the file /proc/vmware/mem.
find Find files under a specified directory that match conditions you specify.
find / -name myfil*
Find files in the root directory and all directories under it that have file names
beginning with myfil. The * is a wild-card character that represents any number of
characters. The ? is a wild-card character that represents a single character.
find -name '*.vmx' -print -exec chown User2 {} \;
Find all files in this directory and all subdirectories that end with .vmx, display the
names of all files that are found on the screen and, for each file (indicated by the curly
braces — {}), change its owner to User2.
The -print option is not necessary, but it is handy to track the progress of the find
command. If you do not use -print, the find command is silent except for error
messages from find or from chown.
find -name '*.vmx' -exec grep -il 'SOMETHING' {} \;
Find all files in this directory and all subdirectories that end with .vmx and look for the
pattern SOMETHING in each of the files. The -i option to grep makes the search
case-insensitive. The -l option to grep causes grep to display the names of the files
that have SOMETHING in them. When a file is found that contains SOMETHING, this
command displays the full path to the file from the current directory (for example,
./virtualmachines/Linux/RedHat71Test/redhat71.vmx).
grep Search for a specified text pattern in a specified directory or list of files and display the
lines in which the pattern is found.
grep "log file" *
Search all the files in the current directory for the text string log file.
less Display the contents of a specified file one screen at a time. Use the arrow keys to
move up and down through the file.
less myfile
Display the contents of the file myfile.
grep "log file" * | less
Search all the files in the current directory for the text string log file and use less
to display the results so you can scroll up and down through them.