transpose-file
This commit is contained in:
parent
27ba58ad99
commit
1b2f15ec8e
|
@ -0,0 +1,3 @@
|
|||
name age
|
||||
alice 21
|
||||
ryan 30
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
lines=$(grep -oP '(?<![^ \n])[^ \n]+(?![^ \n])' file.txt)
|
||||
n=$(sed "1q;d" file.txt | wc -w)
|
||||
top=$(expr $n - 1)
|
||||
for i in $(seq 1 $top); do
|
||||
echo $(echo $lines | tr " " "\n" | awk "NR % $n == $i")
|
||||
done
|
||||
echo $(echo $lines | tr " " "\n" | awk "NR % $n == 0")
|
||||
|
Loading…
Reference in New Issue