Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 May 2013 11:14:01 -0500
From:      Tim Daneliuk <tundra@tundraware.com>
To:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: check variable content size in sh script
Message-ID:  <519505C9.40109@tundraware.com>
In-Reply-To: <20130516154525.GA57497@dan.emsphone.com>
References:  <5194F65F.6080503@a1poweruser.com> <5194FB0A.9090400@tundraware.com> <20130516154525.GA57497@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 05/16/2013 10:45 AM, Dan Nelson wrote:
> In the last episode (May 16), Tim Daneliuk said:
>> On 05/16/2013 10:08 AM, Joe wrote:
>>> Hello
>>>
>>> Have script that has max size on content in a variable.
>>> How to code size less than 51 characters?
>>>
>>
>> FOO="Some string you want to check length of"
>> FOOLEN=`echo $FOO | wc | awk '{print $3}'`
>>
>> You can then use $FOOLEN in a conditional.
>
> Much better way:
>
> FOO="Some string you want to check length of"
> FOOLEN=${#FOO}
>
	

D'Oh, you're right ... what was I thinking ...

<Slinks off in shame ...>

-- 
----------------------------------------------------------------------------
Tim Daneliuk     tundra@tundraware.com
PGP Key:         http://www.tundraware.com/PGP/




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