For best practise, the sed should write to another file, rather than overwriting the original, as sometimes this can 0 the file. so
sed -e 's/setenv NNTPSERVER oldserver/setenv NNTPSERVER newserver/' .cshrc >.cshrc
should be
sed -e 's/setenv NNTPSERVER oldserver/setenv NNTPSERVER newserver/' .cshrc >.cshrc.tmp
mv .cshrc.tmp .cshrc
Main Topics
Browse All Topics





by: soupdragonPosted on 2003-03-18 at 05:31:25ID: 8158841
Something like
#!/usr/bin/ksh
for USER in `cat /etc/passwd | awk -F: '{ print $1 }'`
do
# cd to each home directory in turn
cd ~$USER
# Make a backup of the cshrc if it exists - just in case
if [ -f .cshrc ]
cp -p .cshrc .cshrc.save
# edit it using stream editor
sed -e 's/setenv NNTPSERVER oldserver/setenv NNTPSERVER newserver/' .cshrc >.cshrc
fi
done
- Try it out with a couple first before running the script i.e for USER in 'adam joe'
SD