digitalmars.D.learn - How to use xargs to remove whitespaces (Dub executable path)
- Andre Pany (12/12) Sep 03 2019 Hi,
- H. S. Teoh (7/17) Sep 03 2019 [...]
- Andre Pany (6/26) Sep 04 2019 Thanks a lot. Works fine:)
- Les De Ridder (8/36) Sep 04 2019 It's better to only replace the last occurrence, so it won't
- Sebastiaan Koppe (7/19) Sep 04 2019 What about this?
- Andre Pany (5/30) Sep 04 2019 Thanks to all! Yes replacing spaces with NUL really makes sense.
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? Kind regards André
Sep 03 2019
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 -- Elegant or ugly code as well as fine or rude sentences have something in common: they don't depend on the language. -- Luca De Vitis
Sep 03 2019
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:Thanks a lot. Works fine:) dub describe dscanner --data=target-path,target-name --data-list | xargs | sed -e's g' Kind regards André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
Sep 04 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: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.On Wed, Sep 04, 2019 at 05:52:12AM +0000, Andre Pany via Digitalmars-d-learn wrote:Thanks a lot. Works fine:) dub describe dscanner --data=target-path,target-name --data-list | xargs | sed -e's g'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
Sep 04 2019
On Wednesday, 4 September 2019 at 05:52:12 UTC, Andre Pany 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? Kind regards AndréWhat about this? dub describe scanner --data=target-path,target-name --data-list --data-0 | tr -d '\0' or if you have jq installed: dub describe dscanner | jq '.targets[0].buildSettings | "\(.targetPath)/\(.targetName)"'
Sep 04 2019
On Wednesday, 4 September 2019 at 10:34:28 UTC, Sebastiaan Koppe wrote:On Wednesday, 4 September 2019 at 05:52:12 UTC, Andre Pany wrote:Thanks to all! Yes replacing spaces with NUL really makes sense. Kind regards André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? Kind regards AndréWhat about this? dub describe scanner --data=target-path,target-name --data-list --data-0 | tr -d '\0' or if you have jq installed: dub describe dscanner | jq '.targets[0].buildSettings | "\(.targetPath)/\(.targetName)"'
Sep 04 2019