Search code examples
shellunixawkeditcut

Deleting column with cut or awk from a file in unix


I have the following file in unix:

1098000000199400000099400000010110000000000007000+00000000000001400000032
2010199434117300000017300000010110000000000007000+00000000000000400000009
1010199434117300000017300000010110000000000007000+00000000000000400000009

I need to delete the column that has the "+" in the position 50th using awk or cut command. I was trying to use something like the code below but it handles it like fields, I need to handle this like columns:

awk '{ $50 = ""; print>"new.txt" }' file.txt

Solution

  • You want columns 1 to 49 and everything above 50:

    cut -c1-49,51- file.txt