bug-datamash
[Top][All Lists]
Advanced

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

Re: [Bug-datamash] Datamash cut in v1.5 doesn't support space in csv


From: Assaf Gordon
Subject: Re: [Bug-datamash] Datamash cut in v1.5 doesn't support space in csv
Date: Thu, 17 Oct 2019 16:19:58 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

Hello,

Sorry for the long delay in replying.

On 2019-09-26 2:45 p.m., John Rhee wrote:
$ echo -e "Header 1\tHeader 2\tHeader 3\nData A\tData B\tData C"
Header 1 Header 2 Header 3
Data A Data B Data C

# Column HEADER NUMBER works fine
$ echo -e "Header 1\tHeader 2\tHeader 3\nData A\tData B\tData C" |datamash -H cut 2
cut(Header 2)
Data B

# Column HEADER NAME WITH SPACE does not work
$ echo -e "Header 1\tHeader 2\tHeader 3\nData A\tData B\tData C" |datamash -H cut "Header 2"
datamash: invalid operation ‘2’

This turned out to be just a matter of shell quoting.

When using single-quotes, a single back-slash is needed:

  $ echo [...] | datamash -H cut 'Header\ 2'
  cut(Header 2)
  Data B

When using double-quotes, two back-slashes are needed:

  $ echo [...] | datamash -H cut "Header\\ 2"
  cut(Header 2)
  Data B

When not using quotes at all, three backslashes are needed
(two to pass the backslash character in the parameter to datamash,
and one to escape the backspace):

  $ echo [...] | datamash -H cut Header\\\ 2
  cut(Header 2)
  Data B



Hope this resolves the issue.

regards,
 - assaf




reply via email to

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