bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gawk manual: what if I want the last X chars of a string?


From: Kenny McCormack
Subject: Re: gawk manual: what if I want the last X chars of a string?
Date: 17 Feb 2002 23:54:29 -0600

In article <address@hidden>,
Dan Jacobson <address@hidden> wrote:
....
>Well, the user is not going to get an idea of how to print out the
>last 4 characters of a string ... a least 100 times harder a task then
>printing out the first 4 characters, given he does not know how long
>the string is [so forget just a plain substr()], does not want to use
>a regexp [as perhaps he wants the last 77 chars and all those "..."
>will look confusing] ... anyway, for the user who wants the first X
>chars in a string, answers abound in the manual.  For users who want
>the last X chars in a string, the manual offers no simple one step
>solution.

You're whining.  The problem has nothing to do with "printf" so, it
shouldn't be documented in the printf section.

Anyway, ...

        gawk --re-interval '{print gensub(/.*(.{4})$/,"\\1",1)}'

Happy?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]