shell wildcards

Today I glanced across a ITWorld newsletter with some Unix tips. I knew them all except one.

Well, actually it’s not exactly a tip or even a new command. It’s just a new way of using a command that is quite well known.¬†We’re all familiar with the echo command, I’m sure, but I was quite surprised when I say this:

$ echo *

The wildcard will be expanded and all the files in the local directory will be printed out on one single line separated by spaces.

I stared at it for a moment. It is so brilliantly simple that it’s really amazing.

Of course, you won’t see any files that begin with a ‘.’ and any symbolic links will be listed along with your other files. The biggest problem is if you have filenames with spaces in their name. Not that any unix or linux guy would do that right? But if you do, they’ll show up mixed with the rest of the files.

It’s not perfect, but it’s just so amazingly simple. The echo command has been along since the early versions of unix, and so have shell wildcards, I jest never thought of putting the two together. Old dogs can still learn old tricks after all.