UNIX:合并多个文件,同时删除所有文件的第一行 [英] Unix: merge many files, while deleting first line of all files

查看:638
本文介绍了UNIX:合并多个文件,同时删除所有文件的第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有> 100个文件,我需要合并,但每个文件的第一行已被删除。什么是最有效的方式做到这一点Unix下?我怀疑这是可能使用的 sed的1D命令的的。所有文件具有相同的扩展名,都在同一个文件夹中,所以我们大概可以使用*。扩展名指向文件。非常感谢!

I have >100 files that I need to merge, but for each file the first line has to be removed. What is the most efficient way to do this under Unix? I suspect it's probably a command using cat and sed '1d'. All files have the same extension and are in the same folder, so we probably could use *.extension to point to the files. Many thanks!

推荐答案

假设你的文件名的顺序进行排序,你希望你的文件追加,你可以使用:

Assuming your filenames are sorted in the order you want your files appended, you can use:

ls *.extension | xargs -n 1 tail -n +2

编辑:索林后吉尔斯和有关评论的管道可能发生的危险的 LS 输出,你可以使用:

find . -name "*.extension" | xargs -n 1 tail -n +2

这篇关于UNIX:合并多个文件,同时删除所有文件的第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆