0

I have the following question about UNIX:

What else is needed when the top line goes

#!\bin\awk -f 
 to make it run as a command? 

I am thinking whatever the name of the script is it need to be given permission using chmod to make it run.

2
  • yes it uses \ I forward slash. Commented Oct 5, 2014 at 17:49
  • So one thing that is needed is to replace ` for /`. Commented Oct 5, 2014 at 17:56

2 Answers 2

6

The first line with the "#!" will be a full pathname to the program to be executed.

Pathnames in Linux have the forward slash between directories.

i.e.:

#!/bin/awk -f 

or

#!/bin/bash 

or

#!/usr/bin/perl 

The first script would be run the script program using awk, the second using bash, the third using perl.

You'll also have to make the file executable with:

$ chmod +x myscript.sh 
5

#!\bin\awk -f is a valid shebang line, but it isn't a useful one. It declares that the file must be interpreted by the program called \bin\awk in the current directory. Thus, to answer the question literally, there are two ways to run that file as a command:

  • Create a file called \bin\awk in the current directory, presumably by copying or linking some version of awk. Also, the script needs to be made executable.

    ln -s /bin/awk '\bin\awk' chmod +x /path/to/script /path/to/script 
  • Invoke awk explicitly.

    awk -f /path/to/script 

If modifying the file is allowed, then the shebang line should be edited to make sense: replace the backslashes by slashes. And make the file executable (which is undoubtedly the intended answer, but merely doing that would not be a correct answer).

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.