Subject: Shell hack -- getting files with dates
To: None <netbsd-users@netbsd.org>
From: Jan Danielsson <jan.m.danielsson@gmail.com>
List: netbsd-users
Date: 02/03/2007 23:10:06
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigEADB7851B6B7248D42539089
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello,

   I am processing a list of files using a for loop. However -- I would
like to perform some special processing if the file names contain a
date. I wrote this:

-----------------------------
#!/bin/sh

for f in ~/backup/*.gpg
do
        if echo "$f" | egrep -q '[0-9]{4}-[0-9]{2}-[0-9]{2}' ; then
                echo "$f"
        fi

done
-----------------------------

   ...and it seems to do what I expect it to. What I am actually using
is the return code from egrep -- but is it safe to do it like that? Is
my assumption correct -- that the return code from egrep is simply
"passed through" echo, or will I be seeing odd side effects five years
from now?

--=20
Kind regards,
Jan Danielsson



--------------enigEADB7851B6B7248D42539089
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (NetBSD)

iD8DBQFFxQhDbgs4ia4rq9IRChzIAJoDGNzdqzRGgKkwPT3uJTk4ZTnldwCeMCwA
pDpUARJL551cjlF+WWxum/U=
=aQ9X
-----END PGP SIGNATURE-----

--------------enigEADB7851B6B7248D42539089--