:: Re: [DNG] bash / quote weirdness
Página Principal
Delete this message
Reply to this message
Autor: Steve Litt
Data:  
Para: dng
Assunto: Re: [DNG] bash / quote weirdness
Benjamin Riefenstahl said on Thu, 13 Jan 2022 18:19:23 +0100

>Hi Steve,
>
>Steve Litt writes:
>> [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 ~]$
>
>Different code paths within Bash. When there is a "/" in the command
>name, that is a file that has to exist by that exact name (the file
>name can be relative, though). When there is no "/", then and only
>then the command is searched along $PATH, and if it is not found
>there, the error message is different from the other case.


This is true, but not the explanation for this particular behavior, as
follows:

[slitt@mydesk ~]$ /usr/bin/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 ~]$ "/usr/bin/cat -n" /etc/fstab | cut -b 1-20 | head -n5
bash: /usr/bin/cat -n: No such file or directory
[slitt@mydesk ~]$ "/usr/bin/cat -n /etc/fstab" | cut -b 1-20 | head -n5
bash: /usr/bin/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