1

I have an awk script:

BEGIN { FS="_" }
/^>/ {
    id=$1;p=$2; wild=$3;subs=$4; c=$NF; next
}
{
    if (p-10<1) s=1
    else if (p+10>length($0)) s=length($0)-20
    else s=p-10
    print id"_"p"_"wild"_"subs">\n"substr($0,s,p-s) c substr($0,p+1,21-p+s)
}

and when I run I get the following:

$ cat test1.fasta | awk -f snp_flank.awk
bash: /usr/bin/awk: /usr/bin/awk: bad interpreter: Too many levels of symbolic links

what does this mean?

extra info:

$ ls -l /usr/bin/awk
lrwxrwxrwx 1 root root 21 2011-12-07 16:47 /usr/bin/awk -> /etc/alternatives/awk


$ head -n10 /usr/bin/awk
#!/usr/bin/awk -f

BEGIN { FS="_" }
/^>/ {
    id=$1;p=$2; wild=$3;subs=$4; c=$NF; next
}
{
    if (p-10<1) s=1
    else if (p+10>length($0)) s=length($0)-20
    else s=p-10

it appears I have accidentally replaced awk with an awk script! sorry! how do I fix this? would simply reinstalling awk sort this out?

5
  • 1
    What is /usr/bin/awk on that system? What do file /usr/bin/awk and head -n1 /usr/bin/awk say? Commented Mar 25, 2015 at 15:12
  • 1
    What is the result of the command: ls -l /usr/bin/awk ? Is this file a symbolic link to another file? I think there is a link loop. Commented Mar 25, 2015 at 15:13
  • it appears I have overwritten the awk program with my awk script!! how this happened i do not know. would a simple re-install of awk work? Commented Mar 25, 2015 at 15:24
  • 2
    Yep, that should solve your problem. Commented Mar 25, 2015 at 15:32
  • 3
    Make sure you don't do software development as root. Make sure no-one except root can modify the directory /usr/bin (or /bin, /sbin, /usr/sbin, /etc, etc), and that no-one except root can modify the files in those directories. You should not be able to overwrite /usr/bin/awk running as an ordinary mortal user. Commented Mar 25, 2015 at 15:46

1 Answer 1

1

You have accidentally overwritten /usr/bin/awk.

Reinstall awk on your system.

sudo apt-get install --reinstall gawk

or

sudo yum reinstall gawk

depending on your system.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.