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
相關文章
- [LeetCode] 867. Transpose MatrixLeetCode
- 如何把 image.transpose((2, 0, 1)) 之後,再復原
- ndarray的轉置(numpy.transpose()與A.T命令對比詳解)
- cat > file << EOF 與 cat > file << -
- File
- How to Convert Class File to Java File Online?Java
- docker fileDocker
- include "head_file" 和 include <head_file>
- FUSE File Systems
- 建立DOCKER fileDocker
- Docker Compose fileDocker
- Walking the File Tree
- SQL on file 工具SQL
- gitignore by file size?Git
- JavaScript File 物件JavaScript物件
- log file switch
- 【Java】File類Java
- libmysqlclient.so.16: cannot open shared object file: No such file or directoryIBMMySqlclientObject
- ImportError: libffi.so.7: cannot open shared object file: No such file or directoryImportErrorObject
- 【JAVA :File類的用法(一)】File類的構造方法-File類建立檔案與資料夾Java構造方法
- C#File類C#
- File類的使用
- use "jsdelivr" to host fileJSVR
- DVWA--File Upload
- DWVA--File Inclusion
- File name 屬性
- Reflected File Download Attack
- File getPath()、getAbsolutePath()、getCanonical
- No input file specified.
- File size 屬性
- File type 屬性
- File lastModified 屬性AST
- file_get_content
- 新建 Markdown File (2)
- 樹8 File Transfer
- File 物件詳解物件
- input type="file"使用
- tf.transpose函式的用法講解(多維情況,看似複雜,其實也簡單)函式
- iis 0x80070032 Cannot read configuration file because it exceeds the maximum file size