need help with script and sed

2005-02-18 Thread Jim Pazarena
I would like to traverse my /users/home tree searching
for all regular files and change any lines which read:
  /cgi-bin/Count.cgi ... to:
  http://counter.qcislands.net/cgi-bin/Count.cgi ...
I kinda think that a 'find' with an -exec of 'sed' would do
it but I'm not sure, and even if it were, I'm not sure of
the syntax.
Could someone help me please?
Thanks!
Jim
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: need help with script and sed

2005-02-18 Thread Frank Laszlo
Jim Pazarena wrote:
I would like to traverse my /users/home tree searching
for all regular files and change any lines which read:
  /cgi-bin/Count.cgi ... to:
  http://counter.qcislands.net/cgi-bin/Count.cgi ...
I kinda think that a 'find' with an -exec of 'sed' would do
it but I'm not sure, and even if it were, I'm not sure of
the syntax.
Could someone help me please?
Thanks!
Jim
for i in `find /users/home -type f`; do
   sed -i '' 
s|/cgi-bin/Count.cgi|http://counter.qcislands.net/cgi-bin/Count.cgi|g $i
done

This should do the trick.
Regards,
   Frank Laszlo
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: need help with script and sed

2005-02-18 Thread Bill Moran
Frank Laszlo [EMAIL PROTECTED] wrote:
 Jim Pazarena wrote:
 
  I would like to traverse my /users/home tree searching
  for all regular files and change any lines which read:
/cgi-bin/Count.cgi ... to:
http://counter.qcislands.net/cgi-bin/Count.cgi ...
 
  I kinda think that a 'find' with an -exec of 'sed' would do
  it but I'm not sure, and even if it were, I'm not sure of
  the syntax.
 
  Could someone help me please?
 
  Thanks!
  Jim
 
 
 for i in `find /users/home -type f`; do
 sed -i '' 
 s|/cgi-bin/Count.cgi|http://counter.qcislands.net/cgi-bin/Count.cgi|g $i
 done

The only thing I would recommend different is to provide a backup file
extension to the -i option of sed.  That way it keeps a copy of the file
as it was before sed touches it.  This will save you a lot of headaches,
if sed does something you don't expect.

-- 
Bill Moran
Potential Technologies
http://www.potentialtech.com


pgpEKy22tkSU8.pgp
Description: PGP signature


Re: need help with script and sed

2005-02-18 Thread Frank Laszlo
Bill Moran wrote:
Frank Laszlo [EMAIL PROTECTED] wrote:
 

Jim Pazarena wrote:
   

I would like to traverse my /users/home tree searching
for all regular files and change any lines which read:
 /cgi-bin/Count.cgi ... to:
 http://counter.qcislands.net/cgi-bin/Count.cgi ...
I kinda think that a 'find' with an -exec of 'sed' would do
it but I'm not sure, and even if it were, I'm not sure of
the syntax.
Could someone help me please?
Thanks!
Jim
 

for i in `find /users/home -type f`; do
   sed -i '' 
s|/cgi-bin/Count.cgi|http://counter.qcislands.net/cgi-bin/Count.cgi|g $i
done
   

The only thing I would recommend different is to provide a backup file
extension to the -i option of sed.  That way it keeps a copy of the file
as it was before sed touches it.  This will save you a lot of headaches,
if sed does something you don't expect.
 

Yes, very good call.
__
Frank Laszlo
System Administrator
The VonOstin Group
Email:  [EMAIL PROTECTED]
WWW:http://www.vonostingroup.com
Mobile: 248-863-7584
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]