Searching File in Unix

When I’m using my Opensuse for the first time, I have a hard time to do searching, I don’t know how to do it there is no UI for search like in Windows CMIIW. So I did some googling and this is what I got about find command in Linux.

Find every file under the directory /home owned by the user big.

find /home -user big

Find every file under the directory / (root) ending in “conf”.

find / -name *conf

Find every file under the directory / that was modified more than 30 days ago.

find / -mtime +30

Find files which end with mp3 in or below the directory / and delete them. Note that this will work incorrectly if there are any filenames containing newlines, single or double quotes, or spaces.

find /data -name *mp3 -type f -print | xargs /bin/rm -f

Find files which end with mp3 in or below the directory / and delete them, processing filenames in such a way that file or directory names containing single or double quotes, spaces or newlines are correctly handled.

find /data -name *mp3 -type f -print0 | xargs -0 /bin/rm -f

Actually this article come from this source, I only write half of it, because most user will only do find for these kind of purpose.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s