0

I have an bash script such like below. What I am trying to do is to replace the first column of each FILEIN with value $c excluding the header row (first row), but it doesn't work and output file FILEOUT is same as FILEIN. I can't figure out what's wrong in the script. Somebody has some suggestions?

# /bin/bash

for pheno in ldl vldl 
do
    echo "..processiong $pheno"
    for c in {1..22}
    do  
        echo "..processiong chr$c"
        FILEIN=UVASET2_white-${pheno}_chr${c}.tsv
        FILEOUT=UVASET2_white-${pheno}_CHR${c}.tsv
            awk 'BEGIN {OFS = "\t"} {if(NR>1) $1=$c; print}' $FILEIN >$FILEOUT
    done
done

enter image description here

The first column should be 5 in the above output rather than ---.

David Z
  • 6,641
  • 11
  • 50
  • 101

0 Answers0