Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Wildcard to use in bash shell builtin commands.

I want to cd to say /Applications/XAMPP without typing /Applications/XAMPP.

It doesn't seem I can use "cd app*", is there a wildcard I can use?

Dual 1.8GHz G5, Mac OS X (10.5.6), Wacom 6x11"

Posted on Mar 28, 2011 5:48 PM

Reply
Question marked as Best reply

Posted on Mar 28, 2011 6:02 PM

You forgot the leading slash

cd /App*

8 replies

Mar 29, 2011 5:55 AM in response to wideEyedPupil

sometimes capitals matter some times not

The Mac OS X HFS+ file system is case insensitive, however 'bash' (your shell) is very much case sensitive.

That means if you give the full spelling of a file (no wildcards) but use the wrong case, the shell will not know. Rather it will pass that file name to the command you are invoking, and that command will most likely pass it to the file system asking it to open that file (or change working directory, or get status information on that file, etc...), and since the file system is case insensitive, the file system will find the file regardless of the upper/lower case letters you choose to enter.

If you specify wildcards, then it is the shell (bash) that is going to resolve the wildcard by reading all the files in the directory, and finding the file (or files) that match your wildcard pattern. But since bash is case sensitive, it will only find exact matches for the part of the file name you actually entered.

You can change the bash shell's case sensitive nature using

shopt -s nocaseglob

However, this may have some unintended side-effects if you are going to spend a lot of time in the Unix world, especially if you play on other Unix implementations, as their file systems tend to be totally case sensitive.

Mar 29, 2011 6:31 AM in response to wideEyedPupil

This is Unix. Case always matters. You can get away without correct case with filenames for some file systems on Mac OS X and Mac OS X Server. Mostly. There are other case-sensitive file systems on Mac. You'll also still hit a few corner cases where case matters, even with case-insensitive systems and operations, too; where you encounter some Unix tool where case matters.

As for your request, the wildcard gets all matches, and might not be what you intend. That's filename expansion, and not command completion.

For command-line completion with bash and with the default EDITOR setting, you can invoke completion with either tab or escape, depending on the context.

[Here is a very quick overview of tab and escape completion|http://www.linux.com/archive/feed/54005] for bash.

I would recommend reading a bash book or at least digging around for some bash information (and there's a whole lot of information on bash available), as there is both great power and great subtlety here, and which can both lead to frustration, erroneously deleted files and other mayhem, and also to performing more work than is strictly necessary.

[Here is the Advanced Bash Guide|http://tldp.org/LDP/abs/abs-guide.pdf], which is pretty heavy going, and probably more than you want right now, but you'll learn a whole lot from it regardless. There are lighter introductions around.

Dec 6, 2011 5:39 AM in response to wideEyedPupil

If you find something interesting, you can print the web page and select PDF Save To Disk and create your own directory of notes, articles and related topics. You can then copy the PDF to an iPad, too.


As for your question, here is a copy of the originally-cited web page on bash command line completion from the archive.org Internet archives.


Here is very short generic bash tutorial that covers a few topics in this general area.


And the Bash Beginner's Guide and Advanced Bash-Scripting Guide at the tldp.org site.


Google can be your friend here, too. If one tutorial or one approach doesn't make sense, there are certainly other options and alternatives available.

Wildcard to use in bash shell builtin commands.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.