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?
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.
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.
The classic answer would use sed
to delete lines 1 and 2:
sed 1,2d "$PGLIST"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With