1

So the paragraph is defined by having a empty line at the end.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. 

Nunc et nisi tristique, facilisis orci nec, pellentesque tortor. 

Suspendisse mattis, 

would end up as

Nunc et nisi tristique, facilisis orci nec, pellentesque tortor. 

Suspendisse mattis, 
4
  • you want to remove first paragraph only??
    – Hackaholic
    Nov 9, 2014 at 2:45
  • try this awk 'NR>1{print $0}' file
    – Hackaholic
    Nov 9, 2014 at 2:47
  • @Hackaholic that assumes that the first paragraph is a single line. The {print $0} is not needed by the way, you culd just do awk 'NR>1' file.
    – terdon
    Nov 9, 2014 at 3:06
  • If you like awk try awk 'a==1;/^$/{a=1}'
    – Costas
    Nov 9, 2014 at 10:14

2 Answers 2

3

You already have a great sed approach so here's a Perl way:

$ perl -00ne 'print if $.>1' file 

The -00 turns on "paragraph mode" where a line is defined by \n\n. Then, we print only if the current line number ($.) is >1.

1
  • +1 A magical way to do it: perl -p00e 'BEGIN{<>}' file
    – Joseph R.
    Nov 9, 2014 at 8:03
3

You should be able to delete lines between addresses defined by 1 (the first line of the file) and /^$/ (a regular expression defining an empty line)

sed  '1,/^$/ d' file

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .