Remove odd lines in a text file

File:

/home/USER/DIR/a
http://www.here.is.a.hyper.link.net/
/home/USER/DIR/b
http://www.here.is.another.hyper.link.net/

      

Need to remove all odd lines in this file ( PUBLIC-DIRECTORY-LIST

)? Its for my batch script which can be found below (pubbox batch print creator):

for PATH in `cat LIST`
do
echo $PATH
dropbox puburl $PATH
done > PUBLIC-DIRECTORY-LIST

      

Will I just add a trim command PUBLIC-DIRECTORY-LIST

at the end of the script?

+2


source to share


3 answers


# awk 'NR%2==0' file
http://www.here.is.a.hyper.link.net/
http://www.here.is.another.hyper.link.net/

      



+10


source


I would use awk for this, but this is just me:



awk '{if(i++%2)print}' foo.txt

      

+1


source


For completeness, here's the expression sed

:

sed -e '1d;n;d' file

      

It's like here , except for the extra command 1d

, this removes the first line and therefore prints the odd lines instead of the even ones.

0


source







All Articles