Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Alas we've got this backwards' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Alas we've got this backwards
Authored by: el bid on Mar 14, '02 11:54:12AM

The reason that tcsh complains "No Match" is that same reason the find command as quoted here won't work in bash.

Let's get this straight.

The asterisk in the line:

find . -name [Mm]ac*

...is an invitation to the shell (not to the find command) to glob out the expression _before_ passing it to find. Which isn't what we want to do. And incidentally the [Mm] part of the expression does nothing here, as if you ask the filesystem if there's a file called Mac it will tactfully say yes, even if you actually called it mac. This case-blindness is a, er, feature of HFS+ that we'd better not go into here, as I might get rather cross.

If we don't want the shell (bash or tcsh) to glob out the expression the correct thing in either case is to wrap it in quotes. So:

find . -name "mac*"

... will do what we need. No need at all to mess with the tcsh defaults.

This assumes, of course, that find knows how to do its own globbing, which it does. I mention this because it can bite you in the case of tar. Most proprietory tars can't glob, so:

tar cvf /dev/tape "*.tobebackedup"

...mostly won't work. GNU tar (hurrah!) does the right thing here, however.

--
el bid



[ Reply to This | # ]
Alas we've got this backwards
Authored by: el bid on Mar 16, '02 06:53:04AM
tar cvf /dev/tape "*.tobebackedup"

...mostly won't work. GNU tar (hurrah!) does the right thing here, however.

And just to prove that a guy who's been doing UNIX for ten years can also get it backwards, I've managed to do just that. If you want to save files called this.tobebackedup and that.tobebacked up you do of course want the shell to glob your asterisk, so this is exactly where you wouldn't use quotes. (and of course this will work with any tar, GNU or not).

]]BLUSH[[

What I meant to say was to use quotes to prevent globbing when you're using tar to look into a tarball. Eg, when listing it:

tar tv "*.tobebackedup"

...which is, AFAIK, GNU specific.

Perhaps we can just pretend that the c instead of the t was a slip of the fingers.

--
el bid


[ Reply to This | # ]
Alas we've got this backwards
Authored by: kwenzel on Mar 16, '02 10:40:07AM

Actually, this will work in bash, if there's no file in the CWD that matches the expression. Upon executing:

find . -name curry*

the file ./tmp/curry_comb.jpg will be successfully located - so long as no file matching curry* exists in the CWD.

Having pointed this out, there's still no excuse to expose expressions on the command line.



[ Reply to This | # ]