Re: Need help with SED


Subject: Re: Need help with SED
From: Arthur Corliss (arthur@corlissfamily.org)
Date: Tue Apr 30 2002 - 19:42:31 AKDT


> I'm new to bash scripting, so I a little help on getting going on a
> script I'm trying to write. After reading the man pages for SED, I
> can't figure out what command/switch for sed to use to insert text
> at a specific line in a file. I don't want to change anything
> that's already there, just add two lines of text at line 1422
of /etc/squid/squid.conf
>
> I've already got the code for user input and an "if-then-else" setup
> for execution.

sed '1422a \
<insert text here, escaping new lines>
' squid.conf | new-squid.conf

> Also, is SED the right tool for the job? Or would ED or AWK be
> better?
> (Or even PERL, but I don't want to have to learn the basics of perl
> right yet. No offense Arthur :)

Hey, I'll be the first to tell you that Perl isn't perfect for everything
(damn near, though ;-). I still use awk and sed myself.

--

--Arthur Corliss Bolverk's Lair -- http://arthur.corlissfamily.org/ Digital Mages -- http://www.digitalmages.com/ "Live Free or Die, the Only Way to Live" -- NH State Motto

--------- To unsubscribe, send email to <aklug-request@aklug.org> with 'unsubscribe' in the message body.



This archive was generated by hypermail 2a23 : Wed May 01 2002 - 13:36:48 AKDT