![]() ![]() ![]() Maybe someone could explain this: # ps -ef | egrep 'agetty. Not sure how it works but saves you from having to | grep -v 'grep' on the results. What I tried, is this command: grep -Po 'K' file Above command works fine if I have a space before first pair of ' marks. I want to below words as output: One Two Three Four As you can see all strings in output are between a pair of quotes. Root 28332 4228 0 11:23 pts/2 00:00:00 grep -E agettyįind process matching agetty that also have baud in them: # ps -ef | egrep 'agetty.*baud' the second is here'Two ' and here are in second line' Three ''Four'. Hope it helps.įind processes matching agetty: # ps -ef | egrep agetty The -f flag tells ps to issue a "full-format" listing which you might need to | less when viewing it since longer CLI args might scroll off the right of the terminal and might not wrap. ![]() ie: not all procs show unless you are root). The -e flag tells ps to show all processes (runs with permission of executing user. grep -E is supposed to do the same thing but I got in the habit of using egrep because I wanted a solution which worked across multiple flavors of *nix. A bit long winded, and always thought there must be a better way, so maybe someone can enlighten us both.Įgrep allows for filtering with extended regular expressions which becomes important when you only want "one answer". Always seemed like it should be more useful that what it ends up being. ![]()
0 Comments
Leave a Reply. |