check, that a script is in a folder

Rodolfo Alcazar Portillo nospaze at gmail.com
Wed Jan 5 14:39:32 UTC 2011


On Wed, 2011-01-05 at 02:28 -0800, S Mathias wrote:
> $ echo ${PWD##*/}
> somefolder
> $ if "${PWD##*/}" -eq "asdf" > /dev/null; then echo "this is the asdf folder"; else exit 1; fi
> bash: notthatfolder: command not found...
> this is the asdf folder
> $ 

/home/rodolfoap > mkdir asdf
/home/rodolfoap > cd asdf
/home/rodolfoap/asdf > if [ "${PWD##*/}" == "asdf" ]; then echo "this is the asdf folder"; else exit 1; fi
this is the asdf folder

> What's wrong with my one-liner?

Strings comparison are built with "==" (posix is "=", both works),
integers compare with "-eq". Also, the test command ( or [ ) is
required.

Greets!
----------------------------------------------
Rodolfo Alcazar Portillo - nospaze at gmail.com
otbits.blogspot.com / counter.li.org: #367962
----------------------------------------------
"Absolutely nothing should be concluded from these figures except that
no conclusion can be drawn from them." ~ Joseph L. Brothers




More information about the users mailing list