[CentOS] Cut command behaviour - bug or feature

Les Mikesell lesmikesell at gmail.com
Wed Aug 29 17:23:27 UTC 2012


On Wed, Aug 29, 2012 at 11:52 AM, Markus Falb <markus.falb at fasel.at> wrote:
>>
>> From:
>> http://www.unix.com/unix-dummies-questions-answers/117504-question-cut-command.html
>>
>>  [quote] ... In AIX (for example) if you said
>>
>> Code: echo 1,2,3,4,5 | cut -d, -f3,1,5
>>
>> you would get output as 3,1,5
>
> I tend to think that AIX is not posix compliant, then.
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cut.html
>
> The behaviour of cut makes sense to me, actually. I remember one of
> the UNIX paradigms and thats "do only one thing but do it good"

So sed with a regexp?
 sed  -e 's/\([^,]*\),\([^,]*\),\([^,]*\)/\1\3\2/'

-- 
   Les Mikesell
     lesmikesell at gmail.com



More information about the CentOS mailing list