從一個檔案中讀第3到4行,插入到另一個檔案的第5行后。只用sed命令列,不寫shell腳本,不用邏輯判斷之類的程式語言。最好一個命令列就能解決。
剛學sed,想到這個問題,但做不出來。謝謝。
uj5u.com熱心網友回復:
因為要對兩個檔案操作, 所以只能想到使用兩個sed.sed -n '3,4w temp_file' file1 && sed -i '5r temp_file' file2
uj5u.com熱心網友回復:
sed -n '3,4p' 111.txt | xargs -n 1 -I {} sed -i '5 s/^/{}\n/' 222.txt默認以空格隔開, 如果3,4 行沒有空格的話,可以用這個
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/61844.html
標籤:應用程序開發區
