From owner-freebsd-questions@FreeBSD.ORG Sat May 18 15:15:46 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0640191E for ; Sat, 18 May 2013 15:15:46 +0000 (UTC) (envelope-from quartz@sneakertech.com) Received: from relay01.pair.com (relay01.pair.com [209.68.5.15]) by mx1.freebsd.org (Postfix) with SMTP id 9AB5C64D for ; Sat, 18 May 2013 15:15:45 +0000 (UTC) Received: (qmail 38864 invoked by uid 0); 18 May 2013 15:09:04 -0000 Received: from 173.48.104.62 (HELO ?10.2.2.1?) (173.48.104.62) by relay01.pair.com with SMTP; 18 May 2013 15:09:04 -0000 X-pair-Authenticated: 173.48.104.62 Message-ID: <5197998E.6050200@sneakertech.com> Date: Sat, 18 May 2013 11:09:02 -0400 From: Quartz User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: Devin Teske Subject: Re: check variable content size in sh script References: <5194F65F.6080503@a1poweruser.com> <5194FB0A.9090400@tundraware.com> <13CA24D6AB415D428143D44749F57D7201F4D41F@ltcfiswmsgmb26> In-Reply-To: <13CA24D6AB415D428143D44749F57D7201F4D41F@ltcfiswmsgmb26> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: Tim Daneliuk , "Teske, Devin" , "" X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 May 2013 15:15:46 -0000 > 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: newfoo=${foo:0:51} The three params here are "variable", "start position" and "length". ______________________________________ it has a certain smooth-brained appeal