bash - Shell insert line after last empty line -


I am trying to insert a line of text after the last last line in the middle of a file.

Example file:
  some text more text blah blah blah more blah some more text and even more text   

The inserted text should be on line 6 for that file I have tried such orders so far:

  sed '/ \ n / i some text' file   

but nothing works yet Have not any thoughts? Thank you.

A different solution with grep and awk:

  awk - V end_art_line = $ ([grep-nE '^ [[: empty:]] $ $' your_file | tail-1 | cut-c1 '"{print; if (nr == final_image_line) print" -> something new The text here is inserted with the appropriate grapple which searches for an empty line (or Filled with blank characters only), to choose the last one Pipe Unc.   

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -