[HPADM] [SUMMARY] Unix shell

From: Ben Le (ble@pcc.edu)
Date: Tue Dec 02 2003 - 18:27:12 EST


Is this list great or what? Who need Unix class since we have this list?
Thanks to:
david.totsch@hp.com
bill.thompson@goodyear.com
knikifor@epcor.ca
alexvi@ix.netcom.com
hartman@dutita3.twi.tudelft.nl
Allan.Marillier@dana.com
and OTHER Experts...

Question:
I'd like to replace 'blue' with 'red' in file 'month.log' in 3000+ users
directories. All users are under /home directory. How do I do this. Thanks
for your help.

Solution:

for DIR in /home/*
do
sed s/blue/red/g $DIR/month.log > $DIR/newmonth.log
mv $DIR/newmonth.log $DIR/month.log
done
--------------------------------------------
cd /home
for FILE in */month.log; do
ex $FILE >/dev/null <<EOF
%s/blue/red/g
wq!
EOF
done
---------------------------------------------
perl -p -i -e 's/original text string/replacementstring/g' foo
---------------------------------------------
#!/usr/bin/sh
sed -e "s/blue/red/g" $1 > /tmp/sed.temp$$
if [ $? ]; then # only when the sed went ok!
mv /tmp/sed.temp$$ $1
fi
----------------------------------------------

__________________________________________
Benjamin Le
Sr. Systems Administrator
Information Technology Services
Portland Community College
Voice:(503)-977-4736 Fax:(503)-977-4987
Mailto:ble@pcc.edu http://www.pcc.edu

--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:37 EDT