I need to remove a column from a plain text file. I think this could be done using the inverse of the cut command. I mean, something like this:
If this is my file:
01 Procedimiento_tal retiro aceptado 01 tx1 01 tx2 01 tx3 02 Procedimiento_tal retiro rechazado 02 tx1 02 tx2 02 tx3 03 Procedimiento_tal retiro aceptado 03 tx1 03 tx2 03 tx3 What can I do to remove the first column with cut and get the following text in bash?:
Procedimiento_tal retiro aceptado tx1 tx2 tx3 Procedimiento_tal retiro rechazado tx1 tx2 tx3 Procedimiento_tal retiro aceptado tx1 tx2 tx3 Thanks in advance
The cut command is used to extract the specific portion of text in a file. Many options can be added to the command to exclude unwanted items. It is mandatory to specify an option in the command otherwise it shows an error.
-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(-).
Using cut:
cut -d ' ' -f 2- input-file should do what you want.
To read infile using ' ' as a delimiter (-d) and put fields (-f) 2 onwards (2-) into file:
cut -d' ' -f2- infile > file See man cut for more options.
N.B: This is not bash-specific.
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