How can I delete some columns from a tab separated fields file with awk
?
c1 c2 c3 ..... c60
For example, delete columns between 3 and 29 .
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.
Without GNU awk you need a match() + substr() combo or multiple sub() s + vars to remove a middle field. See also Print all but the first three columns. Note: on Ubuntu Trusty GNU Awk 4.0. 1 doesn't have the awk inplace extension enabled by default.
1) The cut command is used to display selected parts of file content in UNIX. 2) The default delimiter in cut command is "tab", you can change the delimiter with the option "-d" in the cut command. 3) The cut command in Linux allows you to select the part of the content by bytes, by character, and by field or column.
You can cut in awk using awk's function split . You can also filter records using a regex condition within awk, making grep and cut superfluous. This breaks down like: Set the output field separator to be a pipe between two spaces.
This is what the cut
command is for:
cut -f1,2,30- inputfile
The default is tab. You can change that with the -d
switch.
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