Re: insert empty lines with sed (shell script)
From: Andreas Kahari (ak+usenet_at_freeshell.org)
Date: 10/30/03
- Next message: Harald Steden: "Re: insert empty lines with sed (shell script)"
- Previous message: Harald Steden: "insert empty lines with sed (shell script)"
- In reply to: Harald Steden: "insert empty lines with sed (shell script)"
- Next in thread: Harald Steden: "Re: insert empty lines with sed (shell script)"
- Reply: Harald Steden: "Re: insert empty lines with sed (shell script)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Harald Steden: "Re: insert empty lines with sed (shell script)"
- Previous message: Harald Steden: "insert empty lines with sed (shell script)"
- In reply to: Harald Steden: "insert empty lines with sed (shell script)"
- Next in thread: Harald Steden: "Re: insert empty lines with sed (shell script)"
- Reply: Harald Steden: "Re: insert empty lines with sed (shell script)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|