合併子目錄下的檔案

2021-09-11 03:31:30 字數 573 閱讀 2427

比如在當前路徑下有這麼乙個檔案系統:

./0/mytest.en

./1/mytest.en

./2/mytest.en

./3/mytest.en

./4/mytest.en

./5/mytest.en

./6/mytest.en

./7/mytest.en

./8/mytest.en

要把所有的mytest.en貼上到同乙個檔案內,可以使用以下命令:

cat `find ./*/mytest.en` > combine.en
其他形式同理

另外參考:

他是這麼寫的

cat `find $pwd | xargs ls -ld |grep "^-" | awk -f " " ''` >> merge.txt
find $pwd:查詢當前目錄下所有的檔案與資料夾 

xargs:將輸出的輸出的多行內容轉換成一行,也可使用-n 指定每行輸出多少個 

grep 「^-「:只顯示檔案

合併子目錄 hash

題目2 合併子目錄 時間限制 10000ms 單點時限 1000ms 記憶體限制 256mb 小hi的電腦的檔案系統中一共有n個檔案,例如 hihocoder offer22 solutions p1 hihocoder challenge30 p1 test game moba dota2 uni...

python建立子目錄並在子目錄下建立檔案

import os 首先判斷當前工作目錄下是否存在目錄machine learning ifnot os.path.isdir machine learning 不存在的話就建立子目錄machine learning 因為父目錄存在,所有這裡用mkdir也可以 os.makedirs machine...

c 遍歷目錄下所有子目錄及檔案

include include include include include using namespace std 其實兩個字串連在一起比如string可惜寫成 str1 str2 獲取所有的檔名 void getallfiles string path,vector files else 如果...