OpenSource For You

Find more with find

-

find ~ type

find ~ type

f mtime

f mtime

find ~ ! user

The shell sets the environmen­t variable USER to the current username, and a ‘ ! ’ reverses the result of the next test, so this command finds anything in the current user’s directory that is not owned by that user. You can even use find to fix the permission­s:

The output of the above command will show all the files in your home directory modified or created today. By default, find counts days from midnight, so an age of zero means today.

You may have used the -name option with find before, but find can do a lot more. These options can be combined together, so if that elusive download was an MP3 file, you could narrow the search with:

find ~ ! user Have you ever saved a file, maybe a download, and have then been unable to find it? Maybe you saved it in a different directory or with an unusual name.

Here is a command that will help you search for your lost file.

0

0 iname

${USER}

$USER exec

‘*.mp3’

The quotation marks are needed to stop the shell trying to expand the wildcard, and -iname makes the match caseinsens­itive.

Incorrect permission­s can cause obscure errors sometimes. You may, for example, have created a file in your home directory while working as the root. To find files and directorie­s that are not owned by you, use the following command:

sudo chown ${USER}:”{}” \\;

A lot more can be done with find. You can go through the man pages for more details.

—Manikandan, manikandan_vs@yahoo.com

 ??  ??

Newspapers in English

Newspapers from India