paste
paste -d -s -file1 file2
選項含義如下:
-d 指定不同於空格或t a b鍵的域分隔符。例如用@分隔域,使用- d @。
-s 將每個檔案合併成行而不是按行貼上。
- 使用標準輸入。例如ls -l |paste ,意即只在一列上顯示輸出
file1abcfile2123
如何合併兩個檔案,得到
a 1b 2
c 3
awk方式 awk 'nr==fnrnr>fnr' file1 file2
paste方式 paste -d " " file1 file2 > result-file
[root@localhost my_shell]# cat per1id897
id666
id982
[root@localhost my_shell]# cat per2
p.jones
s.round
l.clip
[root@localhost my_shell]# paste per1 per2
id897 p.jones
id666 s.round
id982 l.clip
[root@localhost my_shell]# paste -s per1 per2
id897 id666 id982
p.jones s.round l.clip
————————————————
按行讀取檔案
const string strurlfilename testurl.txt ifstream fin strurlfilename.c str fstream binary if fin fin.eof string serverurl getline fin,serverurl info lo...
python 按行讀取並判斷按行寫入檔案
f open description opinion.json w encoding utf 8 forline inopen test1set raw search.test1.json encoding utf 8 if question type description fact or opi...
Python按行讀檔案
1.最基本的讀檔案方法 file readline example 1.py file open sample.txt while 1 line file.readline if not line break pass do something 一行一行得從檔案讀資料,顯然比較慢 不過很省記憶體。在...