eadmin eadmin eadmin eadmin - 3 months ago 20
Linux Question

creating a blank line after some specific line using bash / linux

I need to add an additional blank line after the line 45 using sed

for example:

44 some text one
45 some text two
46 some text three
47 some text four


44 some text one
45 some text two
47 some text three
48 some text four

I've tried to use

sed '45G' myfile.txt

but not seems to be working, it does prints content of the file on the screen but do not adds any space after the line 45

Using CentOS 7 minimal


You can do:

sed $'45 a \n' file.txt
  • $'' initiates C-style quoting, might be needed in some sed while using \n

  • 45 a \n appends a newline (\n) after (a) the 45-th line