Search this site

Monday, March 19, 2012

Search/find files from terminal in Ubuntu Linux ?

1. Searching Files by names (“-name” option)
To search all “myfav.mp3” file in '/home' directory:

sudo find /home -name 'myfav.mp3'


To search all MP3 files in '/home' directory:
sudo find /home -name '*.mp3'


To do case-sensitive search use “-iname option”:
sudo find /home -iname '*.mp3'

2. Searching Files by Size (“-size” option)

Search all “.avi” files of size greater than 200 Mega Byte:
sudo find /home -name '*.avi' -size +200M

Search all “.avi” files of size lesser than 200 Mega Byte:
sudo find /home -name '*.avi' -size -200M

3. Searching Files by access time (“-atime” option)

Search all “.avi” files how all files that have not been accessed in the “/home” directory for 10 days or more:

sudo find /home -name '*.avi' -atime +30

4.
Searching multiple Files (“-o” option: “OR” operation)

To search myfav1.mp3 OR myfav2.mp3 in “/home” directory:
sudo find /home -name 'myfav.mp3' -o -name 'myfav.mp3'


No comments:

Post a Comment