
g0101_0200.s0194_transpose_file.script.sh Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java17 Show documentation
Show all versions of leetcode-in-java17 Show documentation
Java-based LeetCode algorithm problem solutions, regularly updated
# Read from the file file.txt and print its transposed content to stdout.
# #Medium #Shell #2022_03_04_Time_0_ms_(100.00%)_Space_3.9_MB_(32.21%)
wordcount=$(head -1 file.txt | wc -w)
col_n=1
while [[ $col_n -le $wordcount ]]; do
awk "{ print \$$col_n }" file.txt | paste -sd " "
col_n=$((col_n + 1))
done
© 2015 - 2025 Weber Informatics LLC | Privacy Policy