Syntax error: Bad fd number

I just noticed that (part) of my Makefile could not be executed on my own machine. It gives me a

 /bin/sh: Syntax error: Bad fd number

error. On the target machine this runs fine. My own machine runs Ubuntu but the target machine another linux (RHEL). So what is the difference?

The suspicious line contains a output redirect:

command >&/dev/null

This will run corrent in csh or bash (bash is compatible in this case with csh). But Ubuntu links /bin/sh to dash! You might never heard of dash – me neither.
So I changed the output redirect into something more compatible to solve this problem:

command >/dev/null 2>&1

Tags: , , , , ,

4 Responses to “Syntax error: Bad fd number”

  1. Abhijith says:

    This is time saving. Thank you.

  2. Sungjin says:

    Great I was looking for this solution.

  3. spotleo says:

    Thanks!! Saves me a lot of time!

Leave a Reply