[gllug] echo

Alain Williams addw at phcomp.co.uk
Wed Apr 20 07:54:45 UTC 2005


On Wed, Apr 20, 2005 at 08:28:27AM +0100, Steve Nelson wrote:
> Hi all,
> 
> Just a quickie - I've just discovered (don't laugh!) that 'echo'
> behaves as follows:
> 
> $ echo beer
> beer
> $ echo beer*
> beer*
> $ echo file
> file
> $ echo file*
> file1 file2 file_for_testing
> 
> ie if there is a file matching that which I ask the shell to echo, it
> tells me those files, rather than echoing file*.
> 
> I appreciate that this has to do with shell expansion, such that I can do:
> 
> $ echo 'file*'
> file*
> 
> My question is why this is connected with filenames.  Why does the
> shell look for matching filenames?  ie - Why does echolists all files
> beginning with file.  The echo(1)  manual page doesn't help.
> 
> I'm sure this is blindingly obvious, but I'm curious!

It is done by the shell and not special to echo - which is just another program[**]

To see what is happening switch on shell debugging that shows you the rewritten command
line just before it executes it:

	set -x

for more details:

	man bash

[**] OK - for efficiency echo is built in to most modern shells, but that is
irrelevant.

-- 
Alain Williams
Parliament Hill Computers Ltd.
Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256

#include <std_disclaimer.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20050420/afb4eb54/attachment.pgp>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list