I have a file with three columns. I would like to delete the 3rd column(in-place editing). How can I do this with awk or sed?
123 abc 22.3 453 abg 56.7 1236 hjg 2.3
Desired output
123 abc 453 abg 1236 hjg
Without GNU awk you need a match() + substr() combo or multiple sub() s + vars to remove a middle field.
Use the colrm command to remove specified columns from a file. Input is taken from standard input. Output is sent to standard output. If the command is called with one parameter, the columns of each line from the specified column to the last column are removed.
-c (column): To cut by character use the -c option. This can be a list of numbers separated comma or a range of numbers separated by hyphen(-).
try this short thing:
awk '!($3="")' file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With