$PATH - No such file or directory MAC OSX - Terminal

9,127

You haven't really asked a specific question but here are some comments that hopefully help you understand what's going on:

ad 1

If you just enter

$PATH

into your terminal the shell expands the variable called $PATH and then attempts to execute its contents which, obviously, doesn't make much sense with regards to $PATH. Try running

$ foo=ls
$ $foo

and you will understand what happens. Note though that in most cases you do not want to store a command in a variable, you will want to read BashFAQ/050 aka I'm trying to put a command in a variable, but the complex cases always fail! to learn a little bit about the edge cases and why this is generally a bad idea unless you know exactly what you are doing.

ad 2

Using echo $var you are printing the contents of the variable $var to the screen. Note that word splitting can occur and usually you will want to quote your variables to avoid this:

$ echo "$var"

ad 3

This does not work because cd is a command (OK, a shell builtin usually) and .. is its parameter and the two need to be separated by whitespace so the shell's parser can pick these up as separate tokens:

$ cd ..

Note that you can set up an alias to make cd.. work:

$ alias cd..='cd ..'

but I would advise against that and learn how to properly use a Unix shell instead of making it mimic DOS.

Share:
9,127

Related videos on Youtube

Adrian Frühwirth
Author by

Adrian Frühwirth

Updated on September 18, 2022

Comments

  • Adrian Frühwirth
    Adrian Frühwirth over 1 year

    A million different version of this have been asked already, but I'm still lost, sorry. Here is some of what I'm getting back...

    In a terminal:

    $PATH
    -bash: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin: No such file or directory
    
    echo $PATH
    /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin
    
    cd..
    -bash: cd..: command not found