Shell wrap multiple files to merge _shell command to realize the method of merging multiple files in the current directory into one file...

Shell line break to merge multiple files _shell command to realize the method of merging multiple files in the current directory into one file...
Aberstab’s Russian Buddha Song 2021-01-30 08:31:34 9 Favorites
tags: shell line break merge Multiple files
copyright

Combine multiple files in the current directory into one file

1. Combine multiple files into one file without adding line breaks

find ./ -name "iptv_authenticate_201801*" | xargs cat > iptv_authenticate.txt

2. Set line break ^J

find ./ -name "iptv_authenticate_201801*" | xargs sed 'a\^J' > iptv_authenticate.txt

3. The default line break

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

All suffixes in the current directory are txt files, and a line of data is added as the first line of the file content

1. Method One

for fullpath in `find . -type f -name "*.txt"`

do

sed -i '1i\Num\tPhone\tDate\tMessage\tId\tGudge' ${fullpath}

done

Remarks:

-type f means that the type of the file to be found is file

2. Method two

find . -type f -name "*.txt" | xargs -I {} sed -i '1i\Num\tPhone\tDate\tMessage\tId\tGudge' {}

to sum up

The above is the entire content of this article. I hope that the content of this article has a certain reference value for your study or work. Thank you for your support to Scripthome. If you want to learn more about the relevant content, please check the following related links
——————————————
Copyright statement: This article is the original article of the CSDN blogger "Aberstab’s Russian Buddha Song", Follow the CC 4.0 BY-SA copyright agreement, please attach the original source link and this statement for reprinting.
Original link: https://blog.csdn.net/weixin_34207880/article/details/113540688

Guess you like

Origin blog.csdn.net/wzlsunice88/article/details/114143823