Re: ls -R | grep char_string
"Christoph H." wrote:
>
> > I would like to search all files in the current und subdirs for a
> > char_string.
> > Why does this commandstring not work?:
> >
> > ls -R | grep char_string
> >
> > No error , no nothing - although this certain char_string is in a
> > simple ASCII text file!
>
> You are searching for a string in the name of all files in the
> current dir and subdirs, but I think you want to search for a string
> _within_ all files.
>
> Therefore you have to do something like that:
> find . -exec grep -H char_string {} \; 2>/dev/null
or slightly more effective:
find . -type f |xargs grep char_string /dev/null
it's also more poratable because -H is not as widely supported as the
rest of the above (of course, talking about debian, it is supported...)
also note that 2> works only in sh-derived shells, in csh-derived
shells:
(command > /dev/tty) >& /dev/null
erik
Reply to: