Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Jul 2010 17:45:12 -0600
From:      Chad Perrin <perrin@apotheon.com>
To:        "questions@freebsd.org" <questions@freebsd.org>
Subject:   Re: .sh  check for sufix g or m on size field
Message-ID:  <20100713234512.GA35912@guilt.hydra>
In-Reply-To: <20100712155805.GD2192@libertas.local.camdensoftware.com>
References:  <4C3B26B4.1000208@comclark.com> <20100712155805.GD2192@libertas.local.camdensoftware.com>

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

--7AUc2qLy4jB3hD7Z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Jul 12, 2010 at 08:58:05AM -0700, Chip Camden wrote:
> Quoth Aiza on Monday, 12 July 2010:
> > Sorry miss send, was not done yet.
> >=20
> > Have a .sh script that accepts an -s sparse file size.
> > Only 2 suffix's are valid m and g.
> >=20
> > Been trying to get this line of code to strip out just the single=20
> > letter. But it strips the letter and every thing to the right of it.
> >=20
> > Timagesize=3D`echo-n "${imagesize}" | sed 's/g.*$//'`
> >=20
> > I plan to strip just the m or g if its there and the result should be=
=20
> > numeric. If not numeric know invalid suffix.
> >=20
> > Need help with the sed syntax. Or if there is better way I want to lear=
n=20
> > it.
> >=20
> > Thanks
> > _______________________________________________
> > freebsd-questions@freebsd.org mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd=
.org"
>=20
> It sounds like what you want is simply:
>=20
> sed 's/[gm]//'
>=20
> Or am I missing something?

I get the impression it's something more like this:

    sed 's/[gm]$//'

I'm not sure, but there may be a need to check whether the rest of the
line is solely numeric, too.  The original question was not exactly clear
on that point.

--=20
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]

--7AUc2qLy4jB3hD7Z
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

iEYEARECAAYFAkw8+ogACgkQ9mn/Pj01uKUBpQCguOcZ8Vf1hGO/yBNtK7ime9U0
fk4An0kIlUXuS18Vj+3sbvZC/Mi4uU/5
=kHdA
-----END PGP SIGNATURE-----

--7AUc2qLy4jB3hD7Z--



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