[英]bash - how to remove first 2 lines from output
I have the following output in a text file: 我在文本文件中有以下输出:
106 pages in list
.bookmarks
20130516 - Daily Meeting Minutes
20130517 - Daily Meeting Minutes
20130520 - Daily Meeting Minutes
20130521 - Daily Meeting Minutes
I'm looking to remove the first 2 lines from my output. 我想从输出中删除前两行。 This particular shell script that I use to execute, always has those first 2 lines.
我用来执行的这个特殊shell脚本总是有前两行。
This is how I generated and read the file: 这是我生成和读取文件的方式:
#Lists
PGLIST="$STAGE/pglist.lst";
RUNSCRIPT="$STAGE/runPagesToMove.sh";
#Get List of pages
$ATL_BASE/confluence.sh $CMD_PGLIST $CMD_SPACE "$1" > "$PGLIST";
# BUILD executeable script
echo "#!/bin/bash" >> $RUNSCRIPT 2>&1
IFS=''
while read line
do
echo "$ATL_BASE/conflunce.sh $CMD_MVPAGE $CMD_SPACE "$1" --title \"$line\" --newSpace \"$2\" --parent \"$3\"" >> $RUNSCRIPT 2>&1
done < $PGLIST
How do I remove those top 2 lines? 如何删除前两行?
You can achieve this with tail
: 你可以用
tail
实现这个目标:
tail -n +3 "$PGLIST"
-n, --lines=K output the last K lines, instead of the last 10; or use -n +K to output starting with the Kth
经典答案将使用sed
删除第1行和第2行:
sed 1,2d "$PGLIST"
awk方式:
awk 'NR>2' "$PGLIST"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.