--On July 12, 2010 10:29:08 PM +0800 Aiza <aiz...@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>
pgp0dDi9HpJYK.pgp
Description: PGP signature