|
|
| Author |
Message |
Cardnyl
Luke Warm

Joined: 18 Jan 2004 Posts: 397
Location: FL
|
Posted: 02/10/06 - 16:46 Post subject: Random Linux Question
|
|
|
Any linux-savy people out there familiar with the command line to grep a specific string from a linux man file and then pipe the result someplace else.
I tried the following and it didn't work but it should give you an idea of what Im trying to do.
man awk 2> temp.txt | grep "{print}" | less
Command tries to open the manual for the command awk, dump the standard output to a file called temp, pipe the contents of the file to grep excluding what doesnt match the string in quotes, and redirecting that to less.
If this isnt possible is there any way to search through a multi page manual file for a specific string on a command line interface?
Thanks in advance.
|
|
|
Back to top
|
|
|
|
 |
sinrakin
RealPoor Master of Posts

Joined: 11 Oct 2002 Posts: 7044
|
Posted: 02/10/06 - 17:00 Post subject:
|
|
|
I'm not 100% sure what you're trying to do. What's the purpose of the file temp.txt? You can't "pipe" a file; you can only pipe the output of a command.
It seems like all you really want is
man awk | less
then while you're in less, type
/print
or whatever, to jump to the first/next occurrence of that string so you can see the context around it?
|
|
|
Back to top
|
|
|
|
 |
kemble
RealPoor Sensei

Joined: 14 Oct 2002 Posts: 1912
Location: MI
|
Posted: 02/10/06 - 17:24 Post subject:
|
|
|
| sinrakin wrote: | I'm not 100% sure what you're trying to do. What's the purpose of the file temp.txt? You can't "pipe" a file; you can only pipe the output of a command.
It seems like all you really want is
man awk | less
then while you're in less, type
/print
or whatever, to jump to the first/next occurrence of that string so you can see the context around it? |
Seems to be what he would need.
|
|
|
Back to top
|
|
|
|
 |
motherface
RealPoor Guru

Joined: 12 Mar 2003 Posts: 3407
|
Posted: 02/10/06 - 17:50 Post subject:
|
|
|
|
You can search within the "man" program by typing the / key.
|
|
|
Back to top
|
|
|
|
 |
Cardnyl
Luke Warm

Joined: 18 Jan 2004 Posts: 397
Location: FL
|
Posted: 02/10/06 - 17:53 Post subject:
|
|
|
| sinrakin wrote: | I'm not 100% sure what you're trying to do. What's the purpose of the file temp.txt? You can't "pipe" a file; you can only pipe the output of a command.
It seems like all you really want is
man awk | less
then while you're in less, type
/print
or whatever, to jump to the first/next occurrence of that string so you can see the context around it? |
That is exactly what I was trying to do. Guess I was trying to make it more complicated than it was. I also forgot about the piping thing with regards to files.
I had to go through the man file for less a bit to find out how to search for { print }. I ended up needing to do /^R but either way thats exactly what i was seeking. Thanks again
|
|
|
Back to top
|
|
|
|
 |
|
|