Re: insert empty lines with sed (shell script)

From: Andreas Kahari (ak+usenet_at_freeshell.org)
Date: 10/30/03


Date: Thu, 30 Oct 2003 11:09:24 +0000 (UTC)

In article <bnqqb1$kc2$1@nets3.rz.RWTH-Aachen.DE>, Harald Steden wrote:
> Hello newsgroup,
>
> I would like to insert empty lines into a textfile via sed.
> What I have is the position of the line as a shell variable.
> As I tried several ways to implement this code into my script and did
> not succed, I ask for help here.
> It should look somehow like the following lines, but I do not know how
> to tell sed, the line where it should insert an emty line.
>
> linenumber=`cat $file | egrep -o -o "BLATT 2" sed -e's/:.*//g'`
> sed -e '($linenumber)i\ # the problem is in this line *
> \
> ' < oldfile > newfile

The single quoted sed command won't be interpolated by the
shell. Use double quotes instead:

sed "$linenumber"G oldfile >newfile

(appends a newline followed by the contents of the hold space
(which is empty) after the specified line).

-- 
Andreas Kähäri


Relevant Pages

  • Re: insert empty lines with sed (shell script)
    ... > Hello newsgroup, ... > I would like to insert empty lines into a textfile via sed. ... Linux solution for data management and processing. ...
    (comp.unix.shell)
  • RE: fax cover sheet always empty - need last call made
    ... the using prints the word document to the fax that is ... fax cover page appears with empty fields. ... This newsgroup only focuses on SBS technical issues. ... you may want to contact Microsoft CSS directly. ...
    (microsoft.public.windows.server.sbs)
  • Re: Using Word 2003, when I opening Word I am getting two tabs on task
    ... If you hold CTRL while starting Word ... > contains a blank document and the other is empty. ... The empty one always opens ... This reply is posted in the Newsgroup; please post any follow question or reply ...
    (microsoft.public.word.docmanagement)
  • Re: How do YOU make OWEN"S feel?
    ... 4 out of 5 recommended trolling ... Shawn, the empty barrrel. ... I post all kinds of valuable and topical things to this newsgroup. ... recently posted some questions the Eagles will need to face in training ...
    (alt.sports.football.pro.phila-eagles)
  • RE: fax cover sheet always empty - need last call made
    ... This newsgroup only focuses on SBS technical issues. ... When opening a new thread via the web interface, we recommend you check the ... you may want to contact Microsoft CSS directly. ... fax cover sheet always empty - need last call made ...
    (microsoft.public.windows.server.sbs)