On 1/13/22 09:43, Antony Stone wrote:
On Thursday 13 January 2022 at 15:07:22, Hendrik Boom wrote:

On Wed, Jan 12, 2022 at 05:45:08PM -0500, Steve Litt wrote:

[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

So if it has parameters it's a command, and if it diesn't it's just
a file or directory?

It looks a good deal more complicated than that...

$ "cat /etc/fstab"
bash: cat /etc/fstab: No such file or directory

$ "cat fstab"
bash: cat fstab: command not found

I have no idea what's really going on here.


Antony.

Really very simple. Bash interprets the string in total. It does not parse it for content prior to attempting to execute it. To do that, you need to change the context:
    eval "cat /etc/fstab"
This behavior is well documented on the Bash man page and in all books on shell programming. It is also true for other P-code or interpreted languages such as Perl.

--
William (Bill) Moss
billm...@acm.org
NY (USA)
    Those who will not reason, are bigots,
    those who cannot, are fools,
    and those who dare not, are slaves.
Lord Byron

    Justice will not be served until those who are
    unaffected are as outraged as those who are.
Benjamin Franklin

    When the people fear the government there is
    tyranny, when the government fears the people
    there is liberty.
John Basil Barnhill
_______________________________________________
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng

Reply via email to