[SunHELP] RE: sed script help


Wed Sep 25 21:26:53 CDT 2002


if file contents are:
--snip--
dn: blah1
blah2

dn: blah3
blah4

dn: blah5
blah6
--snip--

and result wanted is:

--snip--
dn: blah1
blah2
changetype: modify
replace: userpassword

dn: blah3
blah4
changetype: modify
replace: userpassword

dn: blah5
blah6
changetype: modify
replace: userpassword
--snip--

then this will work:

--snip--
#!/bin/ksh

#if [ -f $2 ]; then rm $2; fi

while read curr_line
do
 if [[ $(echo ${curr_line} | egrep -c '^dn') > 0 ]]; then
   echo ${curr_line} 
   read curr_line; echo ${curr_line} 
   echo "changetype: modify"
   echo "replace: userpassword"  
 else echo ${curr_line} 
 fi
done < $1
--snip--

otherwise I apologize for misunderstanding. 




-----Original Message-----
From: pelicancomputers [mailto:rfransix at yahoo.com]
Sent: Tuesday, September 24, 2002 12:16 PM
To: sunmanagers at sunmanagers.org
Subject: sed script help


i have a sed script that drops in two lines of text
after every dn:

i have an ldif file where each dn: expands two lines,
my sed script only works when the dn: is one line.

how can i modify this script to drop in lines of text
after the second carriage return after each dn:

#!/bin/sh
sed -e '/^dn:/a\
changetype: modify\
replace: userpassword' < $1 > $2

thank you. rf
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com
_______________________________________________
sunmanagers mailing list
sunmanagers at sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



More information about the SunHELP mailing list