I need to delete string from position X to position Y on each line in a text file

后端 未结 3 1904
轻奢々
轻奢々 2021-01-24 12:57

I have a huge flat file 100K records each spanning 3000 columns. I need to removed a segment of the data fay starting position 300 to position 500 before archiving. This is sens

3条回答
  •  故里飘歌
    2021-01-24 13:38

    Assuming that position means column, you can use cut to select the columns you want.

    cut -f 1-299,501-3000 CutMe.txt
    

    If your data is delimited by commas instead of tabs, then use -d.

    cut -d, -f 1-299,501-3000 CutMe.txt
    

    If position means character, you can do the same with cut -c.

    cut -c 1-299,501-3000 CutMe.txt
    

提交回复
热议问题