Re: Replacing string in multiple files

2003-07-10 Thread Jack L. Stone
At 01:26 PM 7.10.2003 -0500, Dan Nelson wrote:
>In the last episode (Jul 10), Jack L. Stone said:
>> Am running FBSD.4.8-R
>> 
>> At times, I need to replace an existing string in a file that has the same
>> name in all ~user accounts and know there must be a short script to do that
>> and suspect it involves sed(1). However, had no luck getting it to work
>> yet. Basically want to do this:
>> 
>> - find same files in all ~users by same name "~users/myfile"
>> - replace this ${string} with this ${string} in the above files
>> - report list of above files modified successfully
>
>If all your users share a common hierarchy:
>
>sed -i.bak -e s/oldstring/newstring/ /home/*/myfile
>
>You'll need to be running FreeBSD 4.7 or newer for sed -i to work.  Not
>sure how to get a list of changed files, though.  Maybe just do a grep
>beforehand?
>
>-- 
>   Dan Nelson
>   [EMAIL PROTECTED]
>

Thanks, Dan knew it would be simple. Can probably grep and/or diff for
the changes

Best regards,
Jack L. Stone,
Administrator

SageOne Net
http://www.sage-one.net
[EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Replacing string in multiple files

2003-07-10 Thread Dan Nelson
In the last episode (Jul 10), Jack L. Stone said:
> Am running FBSD.4.8-R
> 
> At times, I need to replace an existing string in a file that has the same
> name in all ~user accounts and know there must be a short script to do that
> and suspect it involves sed(1). However, had no luck getting it to work
> yet. Basically want to do this:
> 
> - find same files in all ~users by same name "~users/myfile"
> - replace this ${string} with this ${string} in the above files
> - report list of above files modified successfully

If all your users share a common hierarchy:

sed -i.bak -e s/oldstring/newstring/ /home/*/myfile

You'll need to be running FreeBSD 4.7 or newer for sed -i to work.  Not
sure how to get a list of changed files, though.  Maybe just do a grep
beforehand?

-- 
Dan Nelson
[EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Replacing string in multiple files

2003-07-10 Thread Jack L. Stone
Am running FBSD.4.8-R

At times, I need to replace an existing string in a file that has the same
name in all ~user accounts and know there must be a short script to do that
and suspect it involves sed(1). However, had no luck getting it to work
yet. Basically want to do this:

- find same files in all ~users by same name "~users/myfile"
- replace this ${string} with this ${string} in the above files
- report list of above files modified successfully

That's it. Script help appreciated (csh shells)

Thanks in advance for any suggestions!

Best regards,
Jack L. Stone,
Administrator

SageOne Net
http://www.sage-one.net
[EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"