I have a 3-10 amount of files with:
- different number of columns
- same number of rows
- inconsistent spacing (sometimes one space, other tabs, sometimes many spaces) **within** the very files like the below
> 0 55.4 9.556E+09 33
> 1 1.3 5.345E+03 1
> ........
> 33 134.4 5.345E+04 932
>
........
我需要從文件4從文件3和第1列獲得列(說)1從文件1,從文件2 3列,第7列和將它們並排放入一個文件中。
試驗1:沒有工作
paste <(cut -d[see below] -f1 file1) <(cut -d[see below] -f3 file2) [...]
其中分隔符是 '' 或空。
試驗2:與2檔工作,但不是很多文件
awk '{ a1=$1;b1=$4; getline <"D2/file1.txt"; print a1,$1,b1,$4 }' D1/file1.txt >D3/file1.txt
現在更普遍的問題:
我如何可以提取不同的列許多不同的文件?
如何使用'cut'和'paste'不行? – 2012-10-05 12:34:31
我認爲這是因爲cut假定間距是恆定的。我使用不同的間距格式化數據,以便在每列的左側有數字。如果一個數字有更多的數字,那麼它的左邊會有更少的空間。 – astabada