首先是一些测试文件:
$ cat foo 11 12 13 $ cat bar 21 22 23
一种方法是使用 tail 。 man tail :
tail
man tail
-n, --lines=[+]NUM output the last NUM lines, instead of the last 10; or use -n +NUM to output starting with line NUM
所以:
$ tail -n +2 foo 12 13
但:
$ tail -n +2 foo bar ==> foo <== 12 13 ==> bar <== 22 23
哦,我们需要一个循环:
$ for f in foo bar ; do tail -n +2 "$f" ; done 12 13 22 23
另一种方法是使用awk:
GNU awk文档 说:
FNR FNR is the current record number in the current file. FNR is incremented each time a new record is read (see section Explicit Input with getline). It is reinitialized to zero each time a new input file is started.
$ awk 'FNR>1' foo bar 12 13 22 23
最后,您需要将输出重定向到新文件( one_file ), 例如:
one_file
$ awk 'FNR>1' foo bar > one_file $ cat one_file 12 13 22 23