Reputation: 63
I have a Shell script output file
aa bb
cc dd
eee fff
and want to save this in excel sheet with two columns.
first second
aa bb
cc dd
eee fff
Online browsing I found this
awk 'BEGIN{ OFS=" "; print "first|second"};
NR > 1{print "$0", "$1"}' input.txt > Output.xls
But I do not get the output file.
Upvotes: 0
Views: 3989
Reputation: 247202
set your output field separator to be a comma, and you should be OK:
awk '
BEGIN {OFS=","; print "first", "second"}
{print $1, $2}
' input.txt > Output.xls
With awk, $0
is the complete record and $1
is the first field.
Also, you don't need to skip the first line of input.
Upvotes: 1