What's the difference between these two find commands?
Code:
find . -name *.txt Code:
find . -name \*.txt |
The difference resides in the way the * character is interpreted by the shell. In the first instance the shell expands the wildcard matching all the files with the ".txt" suffix in the current working directory (if any) and the resulting command is something like:
Code:
find . -name fileone.txt filetwo.txt filethree.txt In the second instance the * is protected (escaped) from the shell expansion and the find command actually looks for files ending with .txt under the specified directory tree. |
Well, basically,
Code:
find . -name *.txt Another way is to enclose your argument in quotes; e.g., Code:
find . -name '*.txt' Code:
find . -name '[0-9][0-9]*.txt Code:
find . -name '[Aa][Bb]*.txt You can use the brackets in any position in a file name to isolate a particular pattern. |
Quote:
|
Getting message , find command
find /etc/ -name crond.*
Code:
find: paths must precede expression: cron.hourly |
That's odd, what version of linux are you using? It works flawlessly on my test system.
|
Quote:
I think quoting the wildcard will cause find to do the expansion itself, i.e. -name "crond.*" |
Quote:
|
Quote:
Code:
cd /etc But from ~/ it works. Code:
cd ~/ |
Nod, the previous poster was right, I hadn't realized you were in the /etc directory. Escaping the * should make it work from just about anywhere.
|
Merged 2 closely-related threads.
|
All times are GMT -5. The time now is 03:37 AM. |