From owner-freebsd-questions@FreeBSD.ORG Mon Jul 12 15:42:21 2010 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 178311065675 for ; Mon, 12 Jul 2010 15:42:21 +0000 (UTC) (envelope-from jwebster@es.net) Received: from mailgw.es.net (mail1.es.net [IPv6:2001:400:201:1::2]) by mx1.freebsd.org (Postfix) with ESMTP id EE7C28FC17 for ; Mon, 12 Jul 2010 15:42:20 +0000 (UTC) Received: from myriad.es.net (myriad.es.net [198.128.1.92]) (authenticated bits=0) by mailgw.es.net (8.14.3/8.14.3) with ESMTP id o6CFgGJP014110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 12 Jul 2010 08:42:17 -0700 Date: Mon, 12 Jul 2010 08:42:16 -0700 From: John Webster To: Aiza , questions@freebsd.org Message-ID: <41F18D748529353AB6738881@myriad.es.net> In-Reply-To: <4C3B26B4.1000208@comclark.com> References: <4C3B26B4.1000208@comclark.com> X-Mailer: Mulberry/4.0.8 (Mac OS X) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="==========D3B732B7F3D1B759DE5D==========" X-Proofpoint-Virus-Version: vendor=fsecure engine=1.12.8161:2.4.5, 1.2.40, 4.0.166 definitions=2010-07-12_02:2010-02-06, 2010-07-12, 2010-07-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=5.0.0-1005130000 definitions=main-1007120074 Cc: Subject: Re: .sh check for sufix g or m on size field 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, 12 Jul 2010 15:42:21 -0000 --==========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 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. --==========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==========--