I have a file like this.chr1    14969   14830   2   100(26) 100(31) 100(46) 100(13) 100(26) 100(30) 100(31) 100(36) 100(38)chr1    15795   15039   2   100(3)  100(4)  100(4)  100(3)  100(6)  100(4)  100(2)  100(6)  100(6)chr1    16606   15948   2   80(4)   *(0)    *(0)    100(1)  75(3)   100(3)  66.67(2)    100(3)  *(0)chr1    16606   16311   2   20(1)   *(0)    *(0)    *(0)    25(1)   *(0)    33.33(1)    *(0)    100(1)chr1    16853   16766   2   *(0)    *(0)    *(0)    *(0)    *(0)    *(0)    100(1)  *(0)    100(2)chr1    16857   16766   2   100(2)  100(5)  100(5)  100(1)  100(2)  100(2)  100(2)  100(4)  100(2)chr1    17232   17056   2   100(2)  100(4)  100(8)  100(2)  100(2)  100(7)  100(6)  100(5)  100(3)chr1    17525   17369   2   *(0)    *(0)    100(2)  *(0)    *(0)    *(0)    *(0)    *(0)    *(0)chr1    17605   17056   1   50(9)   38.89(7)    57.89(11)   30(3)   *(0)    *(0)    40.74(11)   65.52(19)   57.14(16)chr1    17605   17369   1   50(9)   61.11(11)   42.11(8)    70(7)   100(3)  100(8)  59.26(16)   34.48(10)   42.86(12)I want to swap column 3 with column 2 and also if column 4 is a 2 replace it with - else with +. The output should look like this.I would like to do this in awk.I tried this to swap the columns. Also I want header line in my output as it isawk -F '\t' -v OFS=\t 'NR > 1{a=$2; $2=$3; $3=a;} 1' fileHow can I change the column 4 to + and - depending upon whether it is 1 or 2 and then print whatever number of columns I have after 4 th column?outputchr1    14969   14830   -   100(26) 100(31) 100(46) 100(13) 100(26) 100(30) 100(31) 100(36) 100(38)chr1    15795   15039   -   100(3)  100(4)  100(4)  100(3)  100(6)  100(4)  100(2)  100(6)  100(6)chr1    16606   15948   -   80(4)   *(0)    *(0)    100(1)  75(3)   100(3)  66.67(2)    100(3)  *(0)chr1    16606   16311   -   20(1)   *(0)    *(0)    *(0)    25(1)   *(0)    33.33(1)    *(0)    100(1)chr1    16853   16766   -   *(0)    *(0)    *(0)    *(0)    *(0)    *(0)    100(1)  *(0)    100(2)chr1    16857   16766   -   100(2)  100(5)  100(5)  100(1)  100(2)  100(2)  100(2)  100(4)  100(2)chr1    17232   17056   -   100(2)  100(4)  100(8)  100(2)  100(2)  100(7)  100(6)  100(5)  100(3)chr1    17525   17369   -   *(0)    *(0)    100(2)  *(0)    *(0)    *(0)    *(0)    *(0)    *(0)chr1    17605   17056   +   50(9)   38.89(7)    57.89(11)   30(3)   *(0)    *(0)    40.74(11)   65.52(19)   57.14(16)chr1    17605   17369   +   50(9)   61.11(11)   42.11(8)    70(7)   100(3)  100(8)  59.26(16)   34.48(10)   42.86(12)Thanks
substituting a column value using awk
awk
With the following awk script named for example script.awk:{    temp=$2    $2=$3    $3=temp    if ( $4 == 2 ) {        $4=-    } else {        $4=+    }    print    temp=''}The following appears to do what you want:$ awk -F '\t' -v OFS='\t' -f script.awk input