Reputation: 53
Hello i have this file.txt
a=a
b=b
c=c
d=d
e=e
f=f
. etc (about 150 rows)
I need the output to be:
a b c d e f ....
a b c d e f ....
I already tried using paste -d " " - - < file.txt
but i need something to work with huge number of rows to columns.
Thank you in advance.
Upvotes: 0
Views: 24
Reputation: 185560
Try this :
awk -F= '{
arr1[NR]=$1
arr2[NR]=$2
}
END{
for (i in arr1) {
printf("%s ", arr1[i])
}
print""
for (i in arr2) {
printf("%s ", arr2[i])
}
print ""
}' file
a b c d e f
a b c d e f
Upvotes: 1
Reputation: 23677
mash of echo
, cut
and tr
$ cat ip.txt
a=1
b=2
c=3
d=4
$ echo $(cut -d= -f1 ip.txt | tr '\n' ' ') ; echo $(cut -d= -f2 ip.txt | tr '\n' ' ')
a b c d
1 2 3 4
Upvotes: 1
Reputation: 8343
You can separate the file using the internal field separator:
while IFS== read -r left right; do echo $left; done < "test.txt" | xargs
This gives you the left side. For the right side, you could do
while IFS== read -r left right; do echo $right; done < "test.txt" | xargs
If you are talking about only 150 rows, scanning the file twice should be finde.
Upvotes: 1