Search code examples
scriptingcshtcsh

unknown error in shell


can somebody explain me what does this error mean:

 > ./rank lines.in
'nknown option: `-
Usage: tcsh [ -bcdefilmnqstvVxX ] [ argument ... ].

this is my script rank:

#! /bin/tcsh -f
set line = `cat ${1}`
echo $line

I think that the problem I have is with first row #! /bin/tcsh -f I'm working on Windows! but after I wrote script on windows editor, I converted it using dos2unix rank, what can be the problem, thanks in advance for any help


Solution

  • I don't think your dos2unix worked. It appears you've still got a \r at the end of the hash-bang line that it doesn't like. It looks like it's seeing /bin/tcsh -f\r, interpreting that as /bin/tcsh -f -\r, and then attempting to print the error message:

    Unknown option: `-\r'
    

    The \r is causing the end quote to appear at the beginning of the line. If you want to see exactly what's in your file try cat -A ./rank to print all hidden characters. You'll probably see

    #! /bin/tcsh -f^M$