leetcode194. Transpose File
Given a text file file.txt, transpose its content.
You may assume that each row has the same number of columns and each field is separated by the ’ ’ character.
For example, if file.txt has the following content:
name age
alice 21
ryan 30
Output the following:
name alice ryan
age 21 30
solution
#!/bin/bash
awk '
{
for(i=1;i<=NF;i++){
if(NR==1){
s[i]=$i;
}
else{
s[i]=s[i]" "$i;
}
}
}
END{
for(i=1;s[i]!="";i++){
print s[i];
}
}
' file.txt
相關文章
- python transposePython
- CUDA SDK例子分析(2):transpose
- [LeetCode] 867. Transpose MatrixLeetCode
- ndarray的轉置(numpy.transpose()與A.T命令對比詳解)
- utl_file.file_type使用
- FILE
- log file sync 和 log file parallel writeParallel
- jQuery :filejQuery
- Bat FileBAT
- SQL SERVER – Attach mdf file without ldf file in DatabaseSQLServerDatabase
- File雜談——初識file控制元件控制元件
- tf.transpose函式的用法講解(多維情況,看似複雜,其實也簡單)函式
- How to Convert Class File to Java File Online?Java
- JavaScript File 物件JavaScript物件
- SQL on file 工具SQL
- log file switch
- 【Java】File類Java
- oracle is not in the sudoers fileOracle
- v$datafile.file#與v$tempfile.file#區別
- Could not find first log file name in binary log index fileIndex
- ORA-27054: NFS file system where the file is created or resides is ......NFSIDE
- ORA-27054: NFS file system where the file is created or resides is not mountedNFSIDE
- ASM file和file alias之間的對映關係!ASM
- data file int write和db file sequential read個人想法
- ORA-27092: skgfofi: size of file exceeds file size limit of the processMIT
- File name 屬性
- File size 屬性
- File type 屬性
- File lastModified 屬性AST
- Docker Compose fileDocker
- gitignore by file size?Git
- File 物件詳解物件
- No input file specified.
- input type="file"使用
- Google File System原理Go
- Oracle ASM File DirectoryOracleASM
- is_file函式函式
- Parse CSV file with Groovy