:: Re: [DNG] [OT] bash / quote weirdne…
Page principale
Supprimer ce message
Répondre à ce message
Auteur: Steve Litt
Date:  
À: dng
Sujet: Re: [DNG] [OT] bash / quote weirdness
Alessandro Vesely via Dng said on Wed, 12 Jan 2022 10:39:07 +0100

>On Wed 12/Jan/2022 01:27:45 +0100 Florian Zieboll via Dng wrote:
>> On Tue, 11 Jan 2022 18:52:10 -0500
>> william moss <bill.m.moss@???> wrote:
>>
>>> Bash is taking the string in the double quotes as a single command;
>>> this is well documented. If either the command or parameters have
>>> spaces, you will have to use eval. Check the bash man page for
>>> details.
>>>
>>> This will also usually work
>>>     X=$( "command and such" )
>>> due to the execute block.  

>>
>> I am replying to the list to share the valid (tested) alternative.
>> Thanks a lot!
>
>
>Bash still considers a quoted command as such, for example:
>
>ale@pcale:~/tmp$ X=$("echo foo")
>bash: echo foo: command not found


On the other hand...

=======================================
[slitt@mydesk ~]$ cat -n /etc/fstab | cut -b 1-20 |  head -n5
     1    UUID=730eaf92
     2    UUID=41abb5fd
     3    UUID=96cfdfb3
     4    UUID=6F66-BF7
     5    tmpfs /tmp tm
[slitt@mydesk ~]$ "cat -n" /etc/fstab | cut -b 1-20 |  head -n5
bash: cat -n: command not found
[slitt@mydesk ~]$ "cat -n /etc/fstab" | cut -b 1-20 |  head -n5
bash: cat -n /etc/fstab: No such file or directory
[slitt@mydesk ~]$
=======================================


SteveT

Steve Litt
Spring 2021 featured book: Troubleshooting Techniques of the Successful
Technologist http://www.troubleshooters.com/techniques