How to escape grep and awk within pipe in an alias?
alias, awk, bash, grep, pipe
Solution
You need to use a function if you want to to insert arguments:
psa() {
ps aux | grep "$1" | awk '{print $2 "\t" $11 }' | grep -v grep
}
Problem
I want to create an alias for an long command. But I'm not able to escape it correct, I guess it's a problem with the pipes. My original command ``` ps aux | grep gimp | awk '{ print $2 '\011' $11 }' | grep -v 'grep' ``` My attempt for an alias ``` alias psa="ps aux | grep $1 | awk '{ print \$2 \"\011\" \$11 }' | grep -v 'grep'" ``` But I get an error that `grep` can not open file `foo` (when I do `psa foo`) When I remove the last part `| grep -v 'grep'` then `awk`throws the same error. I prefer an alias before an shell script.