Reputation: 11
I would like to print first word of first column and second word of second column in to a single column Example:
ABC 123
BCD 987
output:
ABC 987
Upvotes: 0
Views: 850
Reputation: 58371
This might work for you (GNU sed):
sed 'N;s/ .* / /' file
Append the second line to the first and replace everything between the first two spaces with another space.
Upvotes: 0
Reputation: 2471
With sed
sed 'N;s/\([^ ]*\)\(.*\n[^ ]*\)\(.*\)/\1\3/' infile
Or
sed -E 'N;s/([^ ]+)(.*\n[^ ]+)(.*)/\1\3/' infile
Upvotes: 0
Reputation: 67467
this will extract the diagonal for arbitrary size table
$ awk '{print $NR}' file | paste -sd' ' -
Upvotes: 1
Reputation: 16997
awk 'FNR==1{printf $1 OFS;next}FNR==2{print $2;exit}' infile
Upvotes: 1
Reputation: 133458
Sweet and simple awk may help you in same.
awk 'FNR==1{val=$1;next} FNR==2{print val,$2}' Input_file
Upvotes: 1