Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

If I go to a bash prompt and run the following command (to flush memcached):

echo "flush_all" | /usr/bin/nc 11211

it works and returns "OK".

If I put that same command in a one-line bash script:

`echo "flush_all" | /usr/bin/nc 11211`

I get the following output:

: command not found OK

Is it trying to process "OK" as a second command? How can I prevent this (short of redirecting to /dev/null)?

share|improve this question
remove the backticks. – Stéphane Chazelas Feb 13 '13 at 21:59
up vote 1 down vote accepted

With the backticks around the commands, you're attempting to execute the output of:
echo "flush_all" | /usr/bin/nc 11211
In your case "OK"
like already mentioned in the comments just remove the backticks.

share|improve this answer
Wow, now I feel dumb. :) In a prior version of the script the output was being saved to a local variable, so I had the ticks. I removed the variable logic bug left the backticks. Thanks! – Jeremy Mullin Feb 14 '13 at 15:39

This: #!/bin/sh `echo bob` `echo jim`

Is identical to me doing this on the terminal:

# bob
bob: command not found
# jim
jim: command not found

Remove the backticks.

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.