I have to add a column (the same value) with the column name in the already existing tab-delimited file; Do not want to make.
ABCD1 1 1 1 1 1 1
I want a new column header, in Z all the rows have only one value of 2.
ABCZ 1 5 1 2 2 6 6 2 0
How can I do it with Said?
I thought sed "1i Z" | Sed "s / $ / & amp; \ t2 /"
but adds a top of 1li course.
The simplest:
Sed '1 s / $ / \ TZ /; 1! Because the data is strictly different from the tab, I can also see it done with awk: awk - / / / \ t2 / 'filename
F' \ T '' BEGIN {OFS = FS} NR == 1 {$ (NF + 1) = "Z"} NR & gt; 1 {$ (NF + 1) = 2} 1 'File name
Any argument can argue that this is a conceptual cleaner, in the end, both work the same, though. 1
1 Unless there is an empty line, in that case the awk version will be replaced by a new field instead of a new field in line Write.
No comments:
Post a Comment