我有2个文件:testfile1.csv和testfile2.csv。
testfile2.csv:
time,topic3,topic4
2015-10-01,40,50
2015-10-02,45,55
country,uk,uk
testfile1.csv:
time,topic1,topic2
2015-10-01,20,30
2015-10-02,25,35
country,usa,usa
我想将它们组合成一个大文件,测试文件1被复制并且只有1个标题所以我这样做了:
cat test1/testfile1.csv > testfile3.csv
tail -n +2 test1/testfile1.csv test2/testfile2.csv >> testfile3.csv
输出看起来正确,但指示器显示哪个数据集来自哪个文件:
time,topic1,topic2
2015-10-01,20,30
2015-10-02,25,35
country,usa,usa
==> test1/testfile1.csv <==
2015-10-01,20,30
2015-10-02,25,35
country,usa,usa
==> test2/testfile2.csv <==
2015-10-01,40,50
2015-10-02,45,55
country,uk,uk
如何删除指标?我在写tail -n + 2
部分错了吗?
当我使用tail -n +2 test2/testfile2.csv >> testfile2.csv
输出看起来不错但我不想手动逐个文件地做。
预期产出:
time,topic1,topic2
2015-10-01,20,30
2015-10-02,25,35
country,usa,usa
2015-10-01,20,30
2015-10-02,25,35
country,usa,usa
2015-10-01,40,50
2015-10-02,45,55
country,uk,uk
答案 0 :(得分:0)
从手册(man tail
):
-q Suppresses printing of headers when multiple files are being examined.
因此,命令将是:
tail -qn +2 test1/testfile1.csv test2/testfile2.csv >> testfile3.csv