我使用 拆分檔案split -n r/12 file,現在如何連接這 12 個檔案?我試過cat <files>and paste <files>,但使用 diff 后,整個檔案與原始檔案不同。
如何連接這 12 個檔案,以便 cmp/diff 不會顯示差異?paste/cat 使用的任何特殊引數?
uj5u.com熱心網友回復:
回圈拆分是絕對要求嗎?如果不是,你可能只是分成幾個部分:
$split --number=12 file
這將創建 12 個檔案:
$ ls x*
xaa xab xac xad xae xaf xag xah xai xaj xak xal
現在你可以 concat 沒有任何區別:
$cat x* > file.new
$diff file file.new
但是,如果無法繞過回圈要求,我會創建一個 bash 腳本 - 不漂亮。只是提供一個偽代碼
就像是:
Create working directory
Copy all x* files into working directory
Change to working directory
Touch new concatenated file
While all x* files are not empty
Iterate over files in alpha order
Remove the first line in file
Append the line to the new concatenated file
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/407426.html
標籤:
上一篇:為什么我會得到這種輸出?
下一篇:如何創建僅包含檔案的tar檔案
