[PLUG] Help with bash script
David Fleck
dcf at aracnet.com
Tue Aug 6 13:24:36 UTC 2002
On Tue, 6 Aug 2002, Richard Kurth wrote:
> I need some help with a bash script. I need to read a file and find a
> certain line in that file and then add two lines directly after that
> line.
> example
> I need to search the file and find this line. The file is a httpd.conf file
> RewriteRule ^/cgi-bin/test/(.+) proto://servername:81/cgi-bin/test/$1 [L,R]
>
> and then add two lines right below it.
If you are sure the line you're looking for can be uniquely matched by
grep, you can do something like this:
x=`grep -n unique_string httpd.conf | cut -f 1 -d ':'`
head -${x} httpd.conf
echo "line of stuff"
echo "second line of stuff"
x=$((x = x + 1))
tail +${x} httpd.conf
--
David Fleck
dcf at aracnet.com
More information about the PLUG
mailing list