I want to use my awk shortcut as a function, so that I can pass the column number which then prints me the output. My aliases are:
alias A="| awk '{print \$1}'
alias G="| grep -i'
Instad of typing:
ps -ef | grep mysql | awk 'print $2'
I want to be able to type this:
ps -ef G mysql A 2
Any suggestions?
pgrep -f mysql
(assumingpgrep
is available).ps -o <field> $(pgrep mysql)
.ps h -o %p -C mysqld
if you want the PIDs of a particular named process (-C is exact match, not search pattern or regexp). You can have multiple -C args, e.g.ps h -o %p -C mysqld -C mysql
to get client and server processes.