[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: OT: Sed/Perl script tp comment out specifc line
- From: "Anthony E. Greene" <agreene pobox com>
- To: "Red Hat User's Mailing List" <redhat-list redhat com>
- Subject: Re: OT: Sed/Perl script tp comment out specifc line
- Date: Fri, 31 Aug 2001 19:17:53 -0400 (EDT)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Fri, 31 Aug 2001, Chuck wrote:
>I have about 200 remote servers that run a custom application each with
>a tailored config file (ie no two are the same). I need to comment out 2
>lines that are the same in every file for all 200 servers. What is the
>easiest way to do this? I currently use rsh to manage these servers so I
>wanted to create a script, either in perl or sed, that can modify the
>file, distribute this script to each host and execute it there.
>
>How would you guys go about this?
This sounds like a perfect job for a shell script using sed. Make a backup
of the file, then pipe the original through sed into a tempfile. The
tempfile should be exactly two bytes bigger than the original. You can
check it with:
let origsize=`ls --block-size=1 -s origfile | cut -f 1 -d ' '`
let tempsize=`ls --block-size=1 -s tempfile | cut -f 1 -d ' '`
let diffsize="tempsize-origsize"
if [ $diffsize = 2 ]; then
cat tempfile > origfile
else
echo 'sed filter failed'
exit 1
fi
Tony
- --
Anthony E. Greene <agreene pobox com> <http://www.pobox.com/~agreene/>
PGP Key: 0x6C94239D/7B3D BD7D 7D91 1B44 BA26 C484 A42A 60DD 6C94 239D
Chat: AOL/Yahoo: TonyG05
Linux. The choice of a GNU Generation. <http://www.linux.org/>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: Anthony E. Greene <agreene pobox com> 0x6C94329D
iD8DBQE7kBslpCpg3WyUI50RAuLPAKDA0m/mfxt7nv/gyG26HajgXjSNUgCgn2Mx
n0A9ibKV78BWP1v8bTqi1Kw=
=Lhbh
-----END PGP SIGNATURE-----
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]