10

If I know there will be a single folder inside a directory, but I do not know it's name, is there a simple way in bash to go into it? If I wanted to do a check to make sure a folder exists within the current directory, can that be done?

user3475234
  • 1,503
  • 3
  • 22
  • 40

1 Answers1

18

If there is only one sub-directory inside your current path then you can use this glob pattern to do cd:

cd */

Pattern */ matches all the sub-directories from current path and since there is only one so this cd will just change directory to single sub-directory.

anubhava
  • 761,203
  • 64
  • 569
  • 643