Reputation:
I'm automating a workflow with a bash script on Mac OSX. In this workflow, I'd like to add a command that deletes a header from my table (.txt) file that is tab delimited. It looks as follows:
header1 header2 header3
a 1
b 2
c 3
d 4
e 5
f 6
As you can see, the third column, named header3
, is empty.
I've noted this post or this one but I don't understand the arguments.
Could you suggest a line of code that automatically deletes the third column, or (even better) deletes the header called 'header3'?
Upvotes: 1
Views: 740
Reputation:
I found the answer here in Table 2C.
sed s/header3//g input.txt > output.txt
Upvotes: 1
Reputation: 42716
awk
is designed to work with whitespace-separated text columns:
awk '{print $1 "\t" $2}' input.txt > output.txt
Upvotes: 1