這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)碛嘘P(guān)使用shell命令怎么實(shí)現(xiàn)將當(dāng)前目錄下多個(gè)文件合并為一個(gè)文件,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
1、將多個(gè)文件合并為一個(gè)文件沒有添加換行符
find ./ -name "iptv_authenticate_201801*" | xargs cat > iptv_authenticate.txt
2、設(shè)置換行符^J
find ./ -name "iptv_authenticate_201801*" | xargs sed 'a\^J' > iptv_authenticate.txt
3、默認(rèn)換行符
find ./ -name "iptv_authenticate_201801*" | xargs sed 'a\' > iptv_authenticate.txt find ./ -name "iptv_liveswitch_201801*" | xargs sed 'a\' > iptv_liveswitch.txt find ./ -name "iptv_qualified_201801*" | xargs sed 'a\' > iptv_qualified.txt find ./ -name "iptv_vodload_201801*" | xargs sed 'a\' > iptv_vodload.txt
當(dāng)前目錄下所有后綴為txt文件中追加一行數(shù)據(jù)作為文件內(nèi)容的第一行內(nèi)容
1、方法一
for fullpath in `find . -type f -name "*.txt"` do sed -i '1i\Num\tPhone\tDate\tMessage\tId\tGudge' ${fullpath} done
備注:
-type f
是指后邊的查找文件類型為文件
2、方法二
find . -type f -name "*.txt" | xargs -I {} sed -i '1i\Num\tPhone\tDate\tMessage\tId\tGudge' {}
上述就是小編為大家分享的使用shell命令怎么實(shí)現(xiàn)將當(dāng)前目錄下多個(gè)文件合并為一個(gè)文件了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。