From owner-freebsd-questions@FreeBSD.ORG Mon Feb 14 22:54:09 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F902106566B for ; Mon, 14 Feb 2011 22:54:09 +0000 (UTC) (envelope-from rsmith@xs4all.nl) Received: from smtp-vbr10.xs4all.nl (smtp-vbr10.xs4all.nl [194.109.24.30]) by mx1.freebsd.org (Postfix) with ESMTP id A8E0A8FC08 for ; Mon, 14 Feb 2011 22:54:08 +0000 (UTC) Received: from slackbox.erewhon.net (slackbox.xs4all.nl [213.84.242.160]) by smtp-vbr10.xs4all.nl (8.13.8/8.13.8) with ESMTP id p1EMs6is063472; Mon, 14 Feb 2011 23:54:07 +0100 (CET) (envelope-from rsmith@xs4all.nl) Received: by slackbox.erewhon.net (Postfix, from userid 1001) id BAD8ABA90; Mon, 14 Feb 2011 23:54:06 +0100 (CET) Date: Mon, 14 Feb 2011 23:54:06 +0100 From: Roland Smith To: "Jack L. Stone" Message-ID: <20110214225406.GA69832@slackbox.erewhon.net> References: <3.0.1.32.20110214163437.019167e0@sage-american.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="YiEDa0DAkWCtVeE4" Content-Disposition: inline In-Reply-To: <3.0.1.32.20110214163437.019167e0@sage-american.com> X-GPG-Fingerprint: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 X-GPG-Key: http://www.xs4all.nl/~rsmith/pubkey.txt X-GPG-Notice: If this message is not signed, don't assume I sent it! User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: by XS4ALL Virus Scanner Cc: freebsd-questions@freebsd.org Subject: Re: script help X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Feb 2011 22:54:09 -0000 --YiEDa0DAkWCtVeE4 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 14, 2011 at 04:34:37PM -0600, Jack L. Stone wrote: > # find all of the same filenames (copyright.htm) and then replace the year > 2010 with 2011 in each file. Once I have a working script, I should be ab= le > to add it as a cron job to run on the first day of each new year. The following command should do the trick, I think. find / -type f -name copyright.htm -exec sed -i .bak -e 's/Copyright =A9 20= =2E./Copyright =A9 2011/g' {} \; Basically the find(1) command locates the files you want to change, and than for every file it calls sed(1) with the -i flag to do the in-place editing. The originals are saved as copyright.htm.bak. If all goes well, you can delete those. Depending on the contents of the files, you might want to just replace 2010= by 2011, or use a little more context as I did in the example, to make sure on= ly the right numbers are replaced. Roland --=20 R.F.Smith http://www.xs4all.nl/~rsmith/ [plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated] pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725) --YiEDa0DAkWCtVeE4 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (FreeBSD) iEYEARECAAYFAk1Zso4ACgkQEnfvsMMhpyWlmgCgoqeMlJFCBhS/gZo14fsEHNT/ fukAniQ/UANyQUSjBtIIjcDNTUNziYLt =LbtZ -----END PGP SIGNATURE----- --YiEDa0DAkWCtVeE4--