Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash - how to remove first 2 lines from output

Tags:

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.

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?

like image 944
noober Avatar asked Jul 02 '14 22:07

noober


People also ask

How do I ignore the first row in Linux?

The first line of a file can be skipped by using various Linux commands. As shown in this tutorial, there are different ways to skip the first line of a file by using the `awk` command. Noteably, the NR variable of the `awk` command can be used to skip the first line of any file.

What is echo $$ in bash?

The echo command is used to display a line of text that is passed in as an argument. This is a bash command that is mostly used in shell scripts to output status to the screen or to a file.


1 Answers

The classic answer would use sed to delete lines 1 and 2:

sed 1,2d "$PGLIST" 
like image 118
Jonathan Leffler Avatar answered Oct 05 '22 11:10

Jonathan Leffler