Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Feb 2011 23:54:06 +0100
From:      Roland Smith <rsmith@xs4all.nl>
To:        "Jack L. Stone" <jacks@sage-american.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: script help
Message-ID:  <20110214225406.GA69832@slackbox.erewhon.net>
In-Reply-To: <3.0.1.32.20110214163437.019167e0@sage-american.com>
References:  <3.0.1.32.20110214163437.019167e0@sage-american.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110214225406.GA69832>