Free Hosting Online for WorkStations

< Previous | Contents | Next >

3.4.2. Searching for Files and within Files‌


The find directory criteria command searches for files in the hierarchy under directory ac- cording to several criteria. The most commonly used criterion is -name filename, which allows searching for a file by name. You can also use common wildcards such as “*” in the filename search.


$ find /etc -name hosts

/etc/hosts

/etc/avahi/hosts

$ find /etc -name ”hosts*”

/etc/hosts

/etc/hosts.allow

/etc/hosts.deny

/etc/avahi/hosts

$ find /etc -name hosts

/etc/hosts

/etc/avahi/hosts

$ find /etc -name ”hosts*”

/etc/hosts

/etc/hosts.allow

/etc/hosts.deny

/etc/avahi/hosts


The grep expression files command searches the contents of the files and extracts lines matching the regular expression. Adding the -r option enables a recursive search on all files con- tained in the directory. This allows you to look for a file when you only know a part of its contents.

Top OS Cloud Computing at OnWorks: