Results 1 to 4 of 4

Thread: zsh's "cd (directory1|directory2)" in bash

  1. #1
    Join Date
    Dec 2008
    Location
    /dev/null
    Beans
    334

    zsh's "cd (directory1|directory2)" in bash

    Hey,

    How do you do this Zsh's "cd to any of the listed directories" feature in Bash?:
    Code:
    cd (directory1|directory2)
    Because Bash doesn't like it:
    Code:
    bash: syntax error near unexpected token `('
    Thanks for your time,
    Intrepid Ibex
    PC: Asus M5A87, AMD Phenom II X6 1090T, 10GB DDR III 1333MHz, Nvidia GTX560 Ti 1024M, Samsung SSD 830 Series 256GB, HDD 1 TB SATA II 7200RPM
    OS: Arch 64-bit/Windows 8.1 Pro 64-bit
    Other: KB: Logitech G110, M: Logitech G500, 100/10M Internet

  2. #2
    Join Date
    Oct 2010
    Location
    Buffalo, New York
    Beans
    523
    Distro
    Ubuntu

    Re: zsh's "cd (directory1|directory2)" in bash

    Quote Originally Posted by Intrepid Ibex View Post
    Hey,

    How do you do this Zsh's "cd to any of the listed directories" feature in Bash?:
    Code:
    cd (directory1|directory2)
    Because Bash doesn't like it:
    Code:
    bash: syntax error near unexpected token `('
    Thanks for your time,
    Intrepid Ibex
    Can you elaborate on the objective. If I knew the expected outcome I'm sure I'd understand better what it's not doing correctly.

    -- L. James

    --
    L. D. James
    ljames@apollo3.com
    www.apollo3.com/~ljames

  3. #3
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: zsh's "cd (directory1|directory2)" in bash

    You have to enable extglob:
    Code:
    shopt -s extglob
    cd @(directory1|directory2)
    See: `man bash | less +/extglob'

  4. #4
    Join Date
    Dec 2008
    Location
    /dev/null
    Beans
    334

    Re: zsh's "cd (directory1|directory2)" in bash

    Quote Originally Posted by sisco311 View Post
    You have to enable extglob:
    Code:
    shopt -s extglob
    cd @(directory1|directory2)
    See: `man bash | less +/extglob'
    Wow. Thanks.

    Have a Mario Star:
    PC: Asus M5A87, AMD Phenom II X6 1090T, 10GB DDR III 1333MHz, Nvidia GTX560 Ti 1024M, Samsung SSD 830 Series 256GB, HDD 1 TB SATA II 7200RPM
    OS: Arch 64-bit/Windows 8.1 Pro 64-bit
    Other: KB: Logitech G110, M: Logitech G500, 100/10M Internet

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •