Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AWK

0 views
Skip to first unread message

The Magnet

unread,
Jul 9, 2009, 4:28:56 PM7/9/09
to

This is probably so simple, but I cannot figure it out.

I have a string and I want to extract the last 3 characters. x=`echo
$i | awk '{print substr($0,-3,3)}'`

That is not doing it......

Rui Maciel

unread,
Jul 19, 2009, 1:48:56 PM7/19/09
to
The Magnet wrote:

Does the following work?

awk '{print substr($0,length($0)-3,3)}'


Rui maciel

Loki Harfagr

unread,
Jun 3, 2010, 1:22:46 PM6/3/10
to
Sun, 19 Jul 2009 18:48:56 +0100, Rui Maciel did cat :

or, gawkally:
$ echo "lets figure it." | awk '{print substr($0,NF-2,3)}' FS=''
it.

0 new messages