Date: Mon, 12 Jul 2010 08:42:16 -0700 From: John Webster <jwebster@es.net> To: Aiza <aiza21@comclark.com>, questions@freebsd.org Subject: Re: .sh check for sufix g or m on size field Message-ID: <41F18D748529353AB6738881@myriad.es.net> In-Reply-To: <4C3B26B4.1000208@comclark.com> References: <4C3B26B4.1000208@comclark.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--==========D3B732B7F3D1B759DE5D========== Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline --On July 12, 2010 10:29:08 PM +0800 Aiza <aiza21@comclark.com> wrote: > Sorry miss send, was not done yet. > > Have a .sh script that accepts an -s sparse file size. > Only 2 suffix's are valid m and g. > > Been trying to get this line of code to strip out just the single letter. But it strips the letter and every thing to the right of it. > > Timagesize=`echo-n "${imagesize}" | sed 's/g.*$//'` > > I plan to strip just the m or g if its there and the result should be numeric. If not numeric know invalid suffix. > > Need help with the sed syntax. Or if there is better way I want to learn it. > > Thanks Is this what you want? sed -n 's/^\([0-9]\{1,\}[gm]\)$/\1/p' Prints output only if the input begins with digits and ends with g or m. Or this? sed -n 's/^\([0-9]\{1,\}\)[gm]$/\1/p' Prints numeric output only if the input begins with digits and ends with g or m. <http://www.grymoire.com/Unix/Sed.html> <http://sed.sourceforge.net/sed1line.txt> --==========D3B732B7F3D1B759DE5D========== Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (Darwin) iEYEARECAAYFAkw7N9gACgkQBf+aYL5/Y62C/wCdHHH5B2iqLk3mKGma+hVquTRq fwcAnjEgrYCFjRBIjhbQV1/3lyJZcUmL =uxIG -----END PGP SIGNATURE----- --==========D3B732B7F3D1B759DE5D==========--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41F18D748529353AB6738881>