How to use xargs to remove whitespaces (Dub executable path)

Les De Ridder les at lesderid.net
Wed Sep 4 09:32:15 UTC 2019


On Wednesday, 4 September 2019 at 08:23:19 UTC, Andre Pany wrote:
> On Wednesday, 4 September 2019 at 06:40:13 UTC, H. S. Teoh 
> wrote:
>> On Wed, Sep 04, 2019 at 05:52:12AM +0000, Andre Pany via 
>> Digitalmars-d-learn wrote:
>>> Hi,
>>> 
>>> I try to get the executable path from a dub package using 
>>> this command:
>>> 
>>> dub describe dscanner --data=target-path,target-name 
>>> --data-list | xargs
>>> 
>>> But the output always contains a space between target-path 
>>> and target-name: 
>>> /home/user/.dub/packages/dscanner-0.8.0/dscanner/bin/ dscanner
>>> 
>>> How can I get the full path without a space on a debian 
>>> system in a 1 liner?
>> [...]
>>
>> Try:
>> 	... | sed -e's@ @@g'
>>
>>
>> T
>
> Thanks a lot. Works fine:)
> dub describe dscanner --data=target-path,target-name 
> --data-list | xargs | sed -e's@ @@g'

It's better to only replace the last occurrence, so it won't 
break on
paths containing spaces:

     ... | sed 's/\(.*\) /\1/'

There should probably just be a switch to use NUL characters as 
the
delimiter though.




More information about the Digitalmars-d-learn mailing list