[lug] Something seemingly simple

Hugh Brown hugh at math.byu.edu
Tue Dec 19 07:30:57 MST 2006

On Tue, 19 Dec 2006, Daniel Webb wrote:

> I want something to take a space-delimited string and return only the last
> field.  The caveat: the "last field" can have any character except NULL.  How
> can I extract this field from a bash variable or from a file that contains
> such an entry?
> Most obvious ways (bash's 'read' internal, cut, sed) all normally end
> searching for a pattern when they find a newline.  I'm thinking something like
> perl's s///s construction, but I don't want a Perl dependency.  Is it possible
> with the standard GNU toolkit?

So the line is NULL terminated and each field can have anything in it
including newlines?


More information about the LUG mailing list