From owner-freebsd-questions@FreeBSD.ORG Tue Jul 25 14:53:15 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EEB8A16A50C for ; Tue, 25 Jul 2006 14:53:15 +0000 (UTC) (envelope-from parv@pair.com) Received: from mta9.adelphia.net (mta9.adelphia.net [68.168.78.199]) by mx1.FreeBSD.org (Postfix) with ESMTP id 193E843E9A for ; Tue, 25 Jul 2006 14:50:45 +0000 (GMT) (envelope-from parv@pair.com) Received: from default.chvlva.adelphia.net ([69.160.66.115]) by mta9.adelphia.net (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id <20060725145045.GVV16535.mta9.adelphia.net@default.chvlva.adelphia.net>; Tue, 25 Jul 2006 10:50:45 -0400 Received: by default.chvlva.adelphia.net (Postfix, from userid 1000) id 2F55CBB5D; Tue, 25 Jul 2006 10:51:02 -0400 (EDT) Date: Tue, 25 Jul 2006 10:51:02 -0400 From: Parv To: Murray Taylor Message-ID: <20060725145102.GB1157@holestein.holy.cow> Mail-Followup-To: Murray Taylor , freebsd-questions@freebsd.org References: <04E232FDCD9FBE43857F7066CAD3C0F11EEAFA@svmailmel.bytecraft.internal> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <04E232FDCD9FBE43857F7066CAD3C0F11EEAFA@svmailmel.bytecraft.internal> Cc: freebsd-questions@freebsd.org Subject: Re: A question for the AWK wizards X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jul 2006 14:53:16 -0000 in message <04E232FDCD9FBE43857F7066CAD3C0F11EEAFA@svmailmel.bytecraft.internal>, wrote Murray Taylor thusly... > > # generate the sms message > # the awk code forces the message to be < 160 chars ... > tmpfile=`mktemp -t sms` > echo ${phone} >> ${tmpfile} > ${AWK} '{ printf "%-0.159s", $0 }' >> ${tmpfile} << EOF2 > `echo $msg` > EOF2 As it is, any line longer than 159 characters will just overflow. You need to use substr() not awk to shorten a line. Even after that modification, that won't solve your actual problem as the awk script will just shorten EACH line (when record separator is newline), not the whole output. There are ports which seems to do what you want to do. - Parv --