Skip to content

Instantly share code, notes, and snippets.

@YumaInaura
Last active August 28, 2018 08:07
Show Gist options
  • Save YumaInaura/45a96b0c0b9434ba5af0e5dbd293053e to your computer and use it in GitHub Desktop.
Save YumaInaura/45a96b0c0b9434ba5af0e5dbd293053e to your computer and use it in GitHub Desktop.
Zsh — $PATH VS $path

Zsh — $PATH VS $path

Caplital letter $PATH is string

echo $PATH

/Users/yuma/.rbenv/shims:/Users/yuma/.rbenv/bin:./vendor/bin:/Users/yinaura/google-cloud-sdk/bin:/usr/local/opt/openssl/bin:/Users/yuma/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

for loop example

for p in $(echo "$PATH" | sed 's/:/ /g'); do echo "$p"; done

/Users/yuma/.rbenv/shims
/Users/yuma/.rbenv/bin
./vendor/bin
/Users/yinaura/google-cloud-sdk/bin
/usr/local/opt/openssl/bin
/Users/yuma/.pyenv/shims
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

small letter $path is array

echo $path
/Users/yuma/.rbenv/shims /Users/yuma/.rbenv/bin ./vendor/bin /Users/yinaura/google-cloud-sdk/bin /usr/local/opt/openssl/bin /Users/yuma/.pyenv/shims /usr/local/bin /usr/bin /bin /usr/sbin /sbin

for loop example

for p in "${path[@]}"; do echo "$p"; done

/Users/yuma/.rbenv/shims
/Users/yuma/.rbenv/bin
./vendor/bin
/Users/yinaura/google-cloud-sdk/bin
/usr/local/opt/openssl/bin
/Users/yuma/.pyenv/shims
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

In bash case

$path is empty.

bash-4.4$ echo $path

Version

  • zsh 5.5.1 (x86_64-apple-darwin17.5.0)

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment