Bash alias with piping

Posted by n8felton on Super User See other posts from Super User or by n8felton
Published on 2012-03-31T22:02:58Z Indexed on 2012/03/31 23:35 UTC
Read the original article Hit count: 179

Filed under:

I'm not exactly sure what I'm doing wrong with this one. I'm trying to run the command

alias localip='ip -4 -o addr show eth0 | egrep -o '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}' | head -n 1'

If I run the command

ip -4 -o addr show eth0 | egrep -o '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}' | head -n 1

I get the result I expect, however, when trying to create an alias with the command, I get

-bash: syntax error near unexpected token `('

Any help would be appreciated. TIA.

© Super User or respective owner

Related posts about alias