stackjlei
stackjlei

Reputation: 10035

Does terminal aliases with the $ escape it?

Does the $ escape the command? For some reason this shortcut doesn't work for me.

alias killmenow="kill -9 $(lsof -i tcp:3000 -t)"

Upvotes: 0

Views: 62

Answers (1)

rools
rools

Reputation: 1675

Just put it between simple quotes so it is not evaluated during the construction of the alias but when the alias is called:

alias killmenow='kill -9 $(lsof -i tcp:3000 -t)'

Another solution is to escape the dollar:

alias killmenow="kill -9 \$(lsof -i tcp:3000 -t)"

Upvotes: 3

Related Questions