Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How to download awk to Ubuntu, since I tried to use asorti function and it told me that there is an error on this asorti. I tried many scripts that used asorti function and the same error occure!

share|improve this question
1  
Why do you think you need to "downlowd" awk? Please edit your question adding the exact error you are getting when trying to use the asorti function and the output of awk --version –  steeldriver Jan 16 at 17:20
    
@steeldriver the output of awk --version is : ` awk: not an option: --version ` –  user2162652 Jan 16 at 17:37
    
Well, that at least shows that awk is installed. To see what version of awk you have, run awk -W version. Based on the fact that it is installed, you might want to edit your question or create a new one. –  David Edwards Jan 16 at 17:59

1 Answer 1

It sounds like your system is using mawk to provide awk - you can check with

update-alternatives --display awk

If that is the case, you should be able to install GNU awk (gawk) from the repository either using the Software Center or other GUI package manager, or via the command line using

sudo apt-get update
sudo apt-get install gawk

This should automatically set your default awk to gawk using the update-alternatives mechanism - if you need to set it back to mawk you can do so by running

sudo update-alternatives --config awk

and following the on-screen instructions. The asorti function is a GNU awk extension.

share|improve this answer
    
i have run my script using the following : ./project t , but it's give me the following error : ` ./project: line 43: syntax error near unexpected token (' ./project: line 43: num = asorti(myArray)' ` –  user2162652 Jan 16 at 17:55
    
@user2162652 And now what is the output of update-alternatives --display awk? –  Radu Rădeanu Jan 16 at 18:11
    
@RaduRădeanu , the above answer solved partially the problem , but it's still give me a syntax error , on code that has no error , as i said in last comment –  user2162652 Jan 16 at 18:13
    
@user2162652 How can you be sure that the code has no error since it has? And now, what is the output of update-alternatives --display awk? –  Radu Rădeanu Jan 16 at 18:17
    
@RaduRădeanu the output is : awk - auto mode link currently points to /usr/bin/gawk /usr/bin/gawk - priority 10 slave awk.1.gz: /usr/share/man/man1/gawk.1.gz slave nawk: /usr/bin/gawk slave nawk.1.gz: /usr/share/man/man1/gawk.1.gz /usr/bin/mawk - priority 5 slave awk.1.gz: /usr/share/man/man1/mawk.1.gz slave nawk: /usr/bin/mawk slave nawk.1.gz: /usr/share/man/man1/mawk.1.gz Current 'best' version is '/usr/bin/gawk'. –  user2162652 Jan 16 at 18:32

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.