check, that a script is in a folder

Sjoerd Mullender sjoerd at acm.org
Wed Jan 5 10:47:15 UTC 2011


On 2011-01-05 11:28, 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
> $ 
> 
> 
> So i just want to check that i'm in an exact folder. e.g.: "asdf"
> 
> What's wrong with my one-liner?
> 
> I just want to check, that a script is in a folder, and if it isn't, then it exits
> 
> 
>       

if [ "${PWD##*/}" -eq "asdf" ]; then ....

or

if test "${PWD##*/}" -eq "asdf"; then ...

-- 
Sjoerd Mullender

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 371 bytes
Desc: OpenPGP digital signature
Url : http://lists.fedoraproject.org/pipermail/users/attachments/20110105/8d7e0134/attachment.bin 


More information about the users mailing list