Home > linux, Tip > Chopping lines with sed in Linux

Chopping lines with sed in Linux

1) Chop first 1 line from a file
sed -i '1d' filename
[ if need to chop more, simply change 1 to the number of lines to be removed ]
2) Chop last line from a file
sed -i '$d' filename

3) Chop first and last line together from a file
sed -i -e '1d' -e '$d' filename

Advertisements
Categories: linux, Tip
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: