Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I install awk in this version of Ubuntu 11? I installed it from Ubuntu Software Center and I cannot use it.

I'm trying to run an awk script:

#!/bin/awk  
Begin  
{  
print strftime("ora %H, %M , %S");  
}

and I cannot run it because awk is not installed.

./l4p1.sh: /bin/awk: bad interpreter: No such file or directory

share|improve this question

1 Answer 1

up vote 5 down vote accepted

awk is not in /bin, it's in /usr/bin. To find out where you have awk, you can run either of the following:

which -a awk
type awk

Then, change your shebang line accordingly:

#!/usr/bin/awk

… or, even better:

#!/usr/bin/env awk

The latter will just use the version of awk for the current environment, and is portable across different systems that have awk installed somewhere else.

share|improve this answer
    
It's debatable whether #!/usr/bin/env awk is better. It will invoke whichever awk command the current user happens to have first in $PATH. That's usually what you want, but it can cause problems if a particular user has done something odd. –  Keith Thompson Jan 15 '12 at 16:18
1  
@KeithThompson I understand there could be problems with broken per-user installations, but that should rarely be the case. I'm just used to using env, since there are more advantages to it than possible issues. –  slhck Jan 15 '12 at 16:33

Your Answer

 
discard

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.