Skip to content

Commit 8d9d9ed

Browse files
authored
Create 194-transpose-file.sh
1 parent e1f1783 commit 8d9d9ed

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

194-transpose-file.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Read from the file file.txt and print its transposed content to stdout.
2+
awk '
3+
{
4+
for (i = 1; i <= NF; i++) {
5+
if(NR == 1) {
6+
s[i] = $i;
7+
} else {
8+
s[i] = s[i] " " $i;
9+
}
10+
}
11+
}
12+
END {
13+
for (i = 1; s[i] != ""; i++) {
14+
print s[i];
15+
}
16+
}' file.txt

0 commit comments

Comments
 (0)