Saturday, February 04, 2006

How to get the parent directory of a folder

$ dirname `pwd`

In shell script:

VAR=${dirname `pwd`}

2 Comments:

Blogger Unknown said...

${dirname `pwd`}: bad substitution

5:06 PM  
Blogger beattidp said...

Curly braces expand a variable.
Parentheses evaluate and result a string.

PARENTDIR=$(dirname `pwd`)

11:40 AM  

Post a Comment

<< Home