Awk sed tr cut

From Colettapedia
(Redirected from Gawk)
Jump to navigation Jump to search

awk

  • gawk 'program' input-file
  • $ awk "BEGIN { print \"Don't Panic!\" }"
    -| Don't Panic!
  • awk -f source-file input-file1 input-file2
  • command | awk '{print $2}' - print the second column
  • gawk -F $'\\t' 'BEGIN { OFS = \",\";} $4 == \"3\" { print $1, $4, $472, $473, $474; }' ../2017-02-24-Sardinia-TAB.txt > older
  • Print number of columns: awk -F'|' '{print NF; exit}' file.txt
  • make sure file has same number of columns: gawk -F $'\\t' '{print NF}' 20171006_Wave5_Update/20171016_SardiNIA_Complete_WaveI-IV.txt | uniq
  • awk '$3 ~ /^ERCC/ { print $3 }'

cut

  • Also: diff <(cut -d$'\t' -f474 2017-07-07-Sardinia-TAB.txt ) <(cut -d$'\t' -f474 ../2017-02-24-Sardinia-TAB.txt)
  • cut -d " " -f -4059: the fields integer is inclusive and the count starts from ONE not zero
  • paste <(cut -f 3 orig.tsv) <(cut -f 2 orig.tsv) > new.tsv