Re: Removing whitspace from variables in bash?



On Sat, 24 Feb 2007 12:03:13 +0100, Martin Blume wrote:

"IvanMarsh" <annoyed@xxxxxxx> schrieb

If there's a better solution to stripping a leading space out of
something parsed with awk on a character other than a space that can
strip whitespace that would also be helpful.


If there's some way to do this in the original awk line I'd still like
to hear about it.


Something along the lines of:

$ echo " a test" | awk '{sub("^ ", "", $0); print $0}' a test

Cool.

Yes sub works a lot better and with less code.

Thanks all.
.



Relevant Pages

  • Re: Removing whitspace from variables in bash?
    ... If there's a better solution to stripping a leading space out of ... something parsed with awk on a character other than a space ... that can strip whitespace that would also be helpful. ... If there's some way to do this in the original awk line I'd ...
    (alt.os.linux)
  • Re: Using a regexp as field separator does not work!
    ... "field separator" if the regex '| *' is used as FS. ... alternation is used? ... just like an FS of a single blank character is a special case. ... could be optimized and awk doesn't try to analyze and warn you about any of them ...
    (comp.lang.awk)
  • Re: Using a regexp as field separator does not work!
    ... "field separator" if the regex '| *' is used as FS. ... alternation is used? ... just like an FS of a single blank character is a special case. ... could be optimized and awk doesn't try to analyze and warn you about any of them ...
    (comp.lang.awk)
  • Re: Processing columns instead of rows
    ... I have a text processing problem which I think awk should be able to tackle in a better way than I think at present. ... e, it counts the number of times each character occurs in a column, ... and it parses the input file twice, the first time to figure out which ... separate characters may be a gawk extension. ...
    (comp.lang.awk)
  • Re: Using a regexp as field separator does not work!
    ... "field separator" if the regex '| *' is used as FS. ... alternation is used? ... just like an FS of a single blank character is a special case. ... could be optimized and awk doesn't try to analyze and warn you about any of them ...
    (comp.lang.awk)