check variable content size in sh script

Tim Daneliuk tundra at tundraware.com
Thu May 16 16:14:21 UTC 2013


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 at tundraware.com
PGP Key:         http://www.tundraware.com/PGP/



More information about the freebsd-questions mailing list