cd into first/second/third directory returned by ls -d */

0

Say I am in a directory code:

/code
    /very-long-and-descriptive-name

If I want to cd into that directory (or a directory if it comes first in alphabetical order), I can just cd *.

Now say I add more directories and files to code:

/code
    ACKNOWLEDGEMENTS.md
    /a-very-long-directory-name
    /super-long-name-that-is-quite-long
    README.md
    /very-long-and-descriptive-name

Is there a way that I can cd into the (alphabetically ordered) first (a-very), 2nd (super-long) or third (very-long) directory quickly?

Like cd */ 1, cd */ 2, cd */ 3?

Blue Ice

Posted 2014-08-11T22:02:04.943

Reputation: 547

1If you use tab key, it should try to auto-complete. So if you type a and tab, it will expand into a-very-long.., s and tab into super-long..., etc. – NuTTyX – 2014-08-11T22:06:24.267

Wow. I did not know that at all and it solves the issue, so if you make that an answer, I would accept it. – Blue Ice – 2014-08-11T22:12:24.070

Answers

1

If you use tab key, it should try to auto-complete. So if you type a and tab, it will expand into a-very-long.., s and tab into super-long..., etc

NuTTyX

Posted 2014-08-11T22:02:04.943

Reputation: 2 448