Search code examples
regexbashterminalglobcd

Can I use regular expressions with cd command in mac terminal?


I have a directory which contains the following folders.

How do I use cd command to go to folder which contains Intelligence in its name using regular expression?

mac@saurav 6th Semester ->ls
[CE 655] Engineering Economics
[CT 651] Object Oriented Analysis and Design
[CT 652] Database Management System
[CT 653] Artificial Intelligence
[CT 654] Minor Project
[CT 655] Embedded System
[CT 656] Operating System


Solution

  • cd *Intelligence*
    

    would take you to the directory that first matches this pattern.

    Like if there are directories "1 Intelligence", "abc Intelligence" and "bcd Intelligence" in your current directory, it will switch to "1 Intelligence" because it is the first match.