Pete
Pete

Reputation: 314

Bash : space in path access

I tried to access a specific path with a bash script but my terminal won't access to it. Here's my very simple script :

#!/bin/bash
init()
{
    cd $PATH
    ls -l
}
PATH="/Volumes/Macintosh HD/Users"
init

I tried to write "/Macintosh\ HD" without success.

Upvotes: 3

Views: 1385

Answers (1)

Michael Krelin - hacker
Michael Krelin - hacker

Reputation: 143081

Try

cd "$PATH"

note the quotation marks.

Upvotes: 3

Related Questions