bug-coreutils
[Top][All Lists]
Advanced

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

Re: cut feature request - delimiters longer than one character


From: Bob Proulx
Subject: Re: cut feature request - delimiters longer than one character
Date: Sun, 3 Jan 2010 19:48:14 -0700
User-agent: Mutt/1.5.18 (2008-05-17)

Pádraig Brady wrote:
> Nexor wrote:
>> I would love to see the --delimiter option accept (and use) strings
>> longer than one character - what do you think?
>
> Well one often requires more general regular expression matching
> in addition to string matching, and keeping both within a tool like
> sed is probably more cohesive? If one wanted to split on "--" for
> example then you could do somthing like:
>
> echo "1--2--3" | sed 's/--/\x00/g' | cut -d '' -f2

I find awk to be my usual choice when doing things like this.

  $ echo 1--2--3 | awk -F-- '{print$1,$3}'
  1 3

Both awk and sed have an advantage of being standardized and being
readily available in every POSIX environment.

Bob




reply via email to

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