Text document with lines of the form:

000023:AAAB:1111111111111111111122:ABCC:428.15 000025:KCC::В11111111111111111356782:BBC::434.83 

It is necessary to cut the third column on awk separately, which begins after the second separator : in the given example, that is, you need to cut:

 1111111111111111111122 В11111111111111111356782 

with awk -F":" '{ print $3 }' incorrectly cut out because of the double separator :: , which in the document often along with one : therefore, to specify from and to fail. The required field can begin both on a letter, and on figure. Tell me how to cut. Invented | sed 's/\::/:/g' | awk -F":" '{ print $3 }' | sed 's/\::/:/g' | awk -F":" '{ print $3 }' | sed 's/\::/:/g' | awk -F":" '{ print $3 }' - can you do without sed by awk alone?

    1 answer 1

    For the awk command, you can specify a regular expression as a delimiter. Therefore you can write like this

     awk -F':+' '{ print $3 }' 

    Alternatively, you can alternatively (delimiter : or :

     awk -F':|::' '{ print $3 }' 
    • Yes, both work, thanks, I will know! - TWOfish