grep output

hi

i am running grep -c on a bunch of files some of which may be non existent. The output i get is in the same order as the files grep checks and this is what i want as i need to copy the output to a spreadsheet. However when i tried to pipe the output to sed to strip away the filenames and just give me the count the order of the output changes and i get "grep:No such file or directory" as the first line output. Does anybody know of a way round this that i can strip of the filename yet still get the same output order as the input order.

Thanks

[LEFT]Hi,

Try something like this:

$ grep -c linux * none.txt 2>/dev/null | sed 's/.*://'

Regards,
Birei
[/LEFT]

Birei

I dont want to get rid of grep's error message, i just want it to come out in the same order as the input files it recieves ie what happens when you do grep -c

Hi,

Try this. Change my files with yours:

$ grep -c linux lfs.txt none.txt vimdoc.txt 2>&1 | sed 's/.*: *//'
2
No such file or directory
0

Regards,
Birei

hi again birei

This works on linux and cygwin but doesn't on solaris 10. On solaris i get the error output is being passed onto sed which wasnt happening before but the order is still wrong as the error output becomes the first row eventhough it was the second input file in my test. Any ideas?

thanks

Hi,

Sorry. I can't help you with a problem in Solaris because I don't use that SO. As you can see in my last post, it seems to work in my linux, but no idea about Solaris.

Regards,
Birei