当前目录下多个文件合并为一个文件

1、将多个文件合并为一个文件没有添加换行符

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

2、设置换行符^J

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

3、默认换行符

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

当前目录下所有后缀为txt文件中追加一行数据作为文件内容的第一行内容

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' {}

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对免费资源网的支持。如果你想了解更多相关内容请查看下面相关链接

觉得上面的内容有用吗?快来点个赞吧!

点赞() 我要打赏

温馨提示 : 本站内容来自会员投稿以及互联网,所有源码及教程均为作者总结编辑,请大家在使用过程中提前做好备份,以免发生无法预知的错误,源码类教程请勿直接用于生产环境!

 可能感兴趣的文章