Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hithere, how do I watch this command:
netstat -plan|grep :80|egrep -v "(:8082)|(:8080)|(:8081)"|awk {'print $5'}|cut -d: -f 1|sort|uniq -c|sort -n

It errors out when surrounding it with single/double quotes.

share|improve this question
why can't you put the egrep pattern into single quotes, and then wrap the whole thing in double quotes for the watch? – cjc Jul 21 '12 at 11:45
it works, I can also escape the double quotes (forgot about escapes). – w00t Jul 21 '12 at 12:39
up vote 3 down vote accepted
watch "netstat -plan|grep :80|egrep -v \"(:8082)|(:8080)|(:8081)\"|awk {'print $5'}|cut -d: -f 1|sort|uniq -c|sort -n"

You can also do it with single-quotes, but \' inside single quotes doesn't actually escape the single quote, so you end up having to replace every single-quote with '\'', which drives me nuts.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.