Re: search for specific pattern
On 2012-01-14 14:08:36 -0500, Tony Baldwin wrote:
> ls -Rt | grep .cmap
> would list all such files under the current dir, showing the most
> recently edited first.
There are two problems with that. First, by default with grep,
"." will match any character and you may get too much output.
So, instead of
grep .cmap
you may prefer
grep \\.cmap
or
fgrep .cmap
The other problem is that you won't be able to know the directories
that contain the output filenames. A similar solution under zsh,
without this drawback:
ls **/*.cmap(^/)
or
ls -d **/*.cmap
or some other variant, depending on what you want. However, the ls
will be here invoked once all the directories have been searched,
not in parallel of the search like with the other methods, and if
there is too much output, you will get an error due to a kernel
limitation (a workaround is to use a zsh builtin such as printf
instead of ls if you just need the pathname).
> find . -name *.cmp
> would also list all such files.
You need to quote the "*":
find . -name \*.cmap
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Reply to: