Page 1 of 1

Simple piped commands...WTF???

Posted: Fri Jun 15, 2007 6:12 pm
by alex.barylski

Code: Select all

ls -al | cat | grep "Something"
Basically I am trying to search through a list of file contents looking for a match...the above doesn't work...

Anyone care to enlighten me please :)

Posted: Fri Jun 15, 2007 6:26 pm
by feyd
The file contents?

Code: Select all

grep -Pi "something" *
Search all files, show lines where "something" exists (case-insensitive)

Re: Simple piped commands...WTF???

Posted: Fri Jun 15, 2007 6:34 pm
by Weirdan
Hockey wrote:

Code: Select all

ls -al | cat | grep "Something"
Anyone care to enlighten me please :)
Works for me. Btw, cat is unnecessary here.

Posted: Tue Jun 19, 2007 2:02 pm
by alex.barylski
I am trying to locate files with certain class names.

Code: Select all

la -alr | grep class MyClass_*
Doesn't work. I'm listing recursively in the base directory to ensure I list every file which indeed is what is happening, as is demonstrated without the | grep command.

but when I add the grep command (with or without cat) I am getting nothing displayed to screen, maybe I am expecting the wrong results?

How do I get a list of files which match the grep, basically those which have class MyClass_ inside the file?

Cheers :)

Posted: Tue Jun 19, 2007 3:41 pm
by volka
grep class MyClass_*
search all files having a name starting with MyClass_ for the word class. You have to mark class MyClass_* as beeing one parameter with quotes.

Code: Select all

egrep --recursive 'MyClass_' *

Posted: Tue Jun 19, 2007 7:51 pm
by alex.barylski
Got it thanks :)