Remove all text before colon

后端 未结 9 1219
天命终不由人
天命终不由人 2020-11-27 12:45

I have a file containing a certain number of lines. Each line looks like this:

TF_list_to_test10004/Nus_k0.345_t0.1_         


        
9条回答
  •  忘掉有多难
    2020-11-27 13:38

    Below are 2 equivalent solutions:

    The first uses perl's -a autosplit feature to split each line into fields using :, populate the F fields array, and print the 2nd field $F[1] (counted starting from field 0)

    perl -F: -lane 'print $F[1]' file
    

    The second uses a regular expression to substitute s/// from ^ the beginning of the line, .*: any characters ending with a colon, with nothing

    perl -pe 's/^.*://' file
    

提交回复
热议问题