English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

3 answers

The "find" command is great for searching a directory and all subdirectories. But if you only want to search a single directory, you can usually get what you want without it.

For example, to list all files in /tmp whose name contains 'foo' try:

ls /tmp | grep foo

Or to list all files in /tmp which contain the string "bar" try:

grep -l bar /tmp/*

2007-07-26 12:56:26 · answer #1 · answered by McFate 7 · 0 0

1

2017-01-19 15:47:18 · answer #2 · answered by grier 3 · 0 0

There is a find command that will help you to obtain results from a single or specific directory:

# find / -name "apachectl"

find /usr/src -not \( -name "*,v" -o -name ".*,v" \) '{}' \; -print

This command will search in the /usr/src directory and all sub directories. All files that are of the form '*,v' and '.*,v' are excluded. Important arguments to note are:

* -not means the negation of the expression that follows
* \( means the start of a complex expression.
* \) means the end of a complex expression.
* -o means a logical or of a complex expression.
In this case the complex expression is all files like '*,v' or '.*,v'

I hope this helps,.

Thanks

2007-07-26 10:56:42 · answer #3 · answered by Kae76 1 · 0 0

fedest.com, questions and answers