Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have to navigate through a series of directories containing software installers. I've written a small bash function that gets me to the main folder that contains all of the builds, but the file names of the sub-directories are ridiculously long.

The main folder is named "release" and contains directories with names like "Build 10 - 0.0.3580 - ecb871131857710a". I read William Shotts' Jr's book "The Linux Command Line: A Complete Introduction" and it was very good and thorough, but it didn't really give me any insight into solving this problem and my co-workers don't seem to know of a simpler way either.

Can anyone give me any suggestions or general methods that I could research to help solve this problem? I'm not looking for a script or for someone to give me the full on answer, but a little push in the right direction would be greatly appreciated.

share|improve this question

migrated from Apr 5 '13 at 14:54

This question came from our site for professional and enthusiast programmers.

That's a little long, but not ridiculously so. How long is the full path you need to change to? – Barmar Apr 4 '13 at 22:59
What is the problem? You have long filenames, fine. The filesystem can handle them. – alexis Apr 4 '13 at 23:01
Depends on your OS. Here's a way for Ubuntu: – Dave Apr 4 '13 at 23:01
Also you could make shortcuts or just rename the directories – Dave Apr 4 '13 at 23:01
The problem is that my function cd's into the correct directory, but I have to cd with an incredibly long string after that "Build 10 - ..." I could incorporate the build folder into my function, but I'd have to rewrite it every time we released a new build. – Sandwich Heat Apr 4 '13 at 23:10
up vote 0 down vote accepted

I enlightened a guy at school last year by introducing him to the excellence of bash completion while he was reluctantly exploring the superiority of the command line version of Mercurial as opposed to TortoiseHG, per my insistence. The conversation:

Me: Type cd ~

Him: Yes?

Me: Now tab

Him: And?

Me: slash and tab again.

Him: Oh shitt!

Me: Enter. Pretty nifty, yes? Now type the three first letters of the folder where you saved the files.

Him: Ok?

Me: tab

Him: Oh wow! this is really useful!

Me: The powers of command line...

Him: cd Sch[tab][enter] cd Proj[tab][enter] cd s[tab][tab][tab]

Him: It doesn't work

Me: It's case sensitive. Small letters are not the same as big ones. Type Sourc[tab]

Him: Oh. [tab][enter][tab][enter]

Me: No, stop that, you can complete the whole paths, not just individual folders.

Him: Oh shittt! This is so cool!

Me: Next I'll show you how to look for files with locate.

I probably changed his whole life and turned his world view upside down!

share|improve this answer

Linux typically has the following limits:

  #define NAME_MAX         255    /* # chars in a file name */
  #define PATH_MAX        4096    /* # chars in a path name including nul */

If your "ridiculously long" pathnames are shorter than this you shouldn't have a problem.

I notice that your names contain spaces, so make sure you always quote your variables.

share|improve this answer
His question is vague, but I'm pretty sure he's actually asking for a command-line autocomplete. – Dave Apr 4 '13 at 23:04
Yeah, after reading the other comments, I suspect you're right. – Barmar Apr 4 '13 at 23:06
@Dave In that case, it's off-topic for SO. – Barmar Apr 4 '13 at 23:06
Barmar, I'm not sure how it's off topic. Can you please clarify so I don't make this mistake again? – Sandwich Heat Apr 4 '13 at 23:15
Got it, I will adhere to that going forward. Many thanks! – Sandwich Heat Apr 4 '13 at 23:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.