Search code examples
shellcropcut

cut text file and get the last field following a delimeter


I'm having problem to cut/crop the begining of each file line until a delimiter using the cut command.

But doesn't worked.

I've a file full of lines like that :

202008/AX/20200818/20200818_043714rs1fif06.dat:FG0620200817FR1      RCRGBRJ360100000000000115600000003470000000416340000000693900000013878 

I want to cut the begining of the line to leave as exit

FG0620200817FR1         RCRGBRJ360100000000000115600000003470000000416340000000693900000013878   

I thought to use ':' or 'rs1fif06.dat' as delimiters. Using the following cut command :

cut -d':' filename 

That's doesn't worked and i don't know why. or

cut -d'rs1fif06.dat:' filename 

That's doesn't worked as i read because cut command doesn't allow such words as delimiters.


Solution

  • cut tells you what you have to do:

    $ cut -d:
    cut: you must specify a list of bytes, characters, or fields
    Try 'cut --help' for more information.
    

    So leave the second field.

    cut -d: -f2