Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Jul 2006 10:51:02 -0400
From:      Parv <parv@pair.com>
To:        Murray Taylor <MTaylor@bytecraft.com.au>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: A question for the AWK wizards
Message-ID:  <20060725145102.GB1157@holestein.holy.cow>
In-Reply-To: <04E232FDCD9FBE43857F7066CAD3C0F11EEAFA@svmailmel.bytecraft.internal>
References:  <04E232FDCD9FBE43857F7066CAD3C0F11EEAFA@svmailmel.bytecraft.internal>

next in thread | previous in thread | raw e-mail | index | archive | help
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

-- 




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