Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I have a bashscript which uses grep with awk as following:

#ec2-describe-instances | grep -i instance | awk '{print "Creating -> " $3; system("ec2-create-image " $2 " --name " $3 "-$(date +%F) --no-reboot ")}'

Unfortunately there seems to be an error.
And unfortunately the console output is empty.

How can I output the errors to console?

share|improve this question
Assuming your prompt is #. What happens when you do ec2-describe-instances | grep -i instance -- is there output for awk to consume? – glenn jackman May 23 '14 at 17:41
@glenn jackman - That is one which is a bit strange with this line, scripts usually include a space even for comments, and when they signify a root prompt they include the full prompt, such as 'root@computername:/currentworkingdir#'. The # could be a $, but the ec2-xx cannot be a variable, it must a script name. In that case most user scripts start with ./script unless it is elevated to root. Speaking strictly of bash of course. – arch-abit May 23 '14 at 18:07
@arch-abit, if the script is in PATH, then it doesn't require the ./ before it. When I provide BSD commands to customers, I often precede each line with a # and I don't always put a space (either forget or get lazy). In any case, unless we know more about 'ec2-describe-instances' and what it is supposed to output, it is not possible to tell what might be wrong with any thing that manipulates that output. – MaQleod May 23 '14 at 20:46
@MaQleod - thanks, you are correct. 'Use the PATH, Luke!' :) – arch-abit May 23 '14 at 21:15

Remove the pound sign from the beginning of the script. For the bash shell a # sign is a comment line.

EDIT: Anything bash reads from script or from user input starting with a # bash ignores, and Unix/Linux being terse no output is given. There are some exceptions to this, but they do not seem to apply to your script.

If you copied the script from somewhere the pound sign was not meant to be part of the script. It is commented out, so remove it to make it work

If you are new to bash there is a good starter tutorial here.

share|improve this answer
The pound may simply be the prompt. It isn't the most common, but it is used (eg freebsd). – MaQleod May 23 '14 at 17:41

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.