I want to delete all the text after the second underscore (including the underscore itself), but not on every line. Every of the target lines begin with a pattern (>gi_). EXAMPLE.Input>gi_12_pork_catACGT>gi_34_pink_blueCGTAOutput>gi_12ACGT>gi_34CGTA
Delete everything after second underscore
text processing;command line;bioinformatics
$ awk -F_ 'BEGIN {OFS=_} /^>gi/ {print $1,$2} ! /^>gi/ {print}' input>gi_12ACGT>gi_34CGTA