puzzled by grepping on man output -- some strings found, others not
I'm attempting to grep on man output for convenience, and had the following curious result. The first search is picked up, but the second search (on "bashrc") has no results.
I guess this question basically boils down to a sane way of getting man output to stdout so I can pipe it to wherever. -P cat probably isn't the right way to do this. so what is? $:~/shellenv> man -P cat bash | grep "executes commands from" in that order, and reads and executes commands from the first one that reads and executes commands from ~/.bashrc, if that file exists. This reads and executes commands from ~/.bashrc, if that file exists and is $:~/shellenv> man -P cat bash | grep "bashrc" $:~/shellenv> |
This is what I get:
Code:
@FREEWILL:~$ man -P cat bash | grep "executes commands from" |
These both work on my machine (Mepis/bash shell):
man bash|grep bashrc man bash|grep "bashrc" Note that the quotes are not required in grep unless you have a regex or the search string has whitespace. |
The output from man will contain backspaces and underline characters. The instances of "bashrc" in the manpage appear as bashrc. That is why your grep doesn't find them. You could instead pipe the output of the manpage through the "col" command.
man bash | col -b | grep bashrc Reformatting bash(1), please wait... tialization file ~/.bashrc if the shell is interactive (see ~/.bashrc if the shell is interactive. This option is on by reads and executes commands from ~/.bashrc, if that file exists. This ~/.bashrc. reads and executes commands from ~/.bashrc, if that file exists and is initialize the shell, as in ~/.bashrc. The value of BASH_ENV is ~/.bashrc Of course it would be better to use the '/' key to start a search when reading a manpage. |
Quote:
|
Moved: This thread is more suitable in Linux-Software and has been moved accordingly to help your thread/question get the exposure it deserves.
|
All times are GMT -5. The time now is 09:31 AM. |