check variable content size in sh script

Quartz quartz at
Sat May 18 15:15:46 UTC 2013

> However, if the OP wanted to actually truncate $FOO to 51
> characters:
> NEWFOO=$( echo "$FOO" | awk -v max=51 '{print substr($0,0,max)}' )

You don't need all that for a simple truncation/substring, you can do it 
with a direct assignment:


The three params here are "variable", "start position" and "length".

it has a certain smooth-brained appeal

More information about the freebsd-questions mailing list