puzzled by grepping on man output -- some strings found, others not
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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>
@FREEWILL:~$ man -P cat bash | grep "executes commands from"
Reformatting bash(1), please wait...
in that order, and reads and executes commands from the first one that
reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if
FREEWILL:~$ man -P cat bash | grep "bashrc"
Reformatting bash(1), please wait...
ization file /etc/bash.bashrc and the standard personal initial‐
ization file ~/.bashrc if the shell is interactive (see INVOCA‐
/etc/bash.bashrc and the personal initialization file ~/.bashrc
reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if
from file instead of /etc/bash.bashrc and ~/.bashrc.
reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if
initialize the shell, as in ~/.bashrc. The value of BASH_ENV is
/etc/bash.bashrc
~/.bashrc
@FREEWILL:~$
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.