check, that a script is in a folder

S Mathias smathias1972 at yahoo.com
Wed Jan 5 15:07:40 UTC 2011


solved:

if ! [ "${PWD##*/}" == "ASDF" ]; then echo "error: not the ASDF dir"; exit 1; fi

--- On Wed, 1/5/11, Rodolfo Alcazar Portillo <nospaze at gmail.com> wrote:

> From: Rodolfo Alcazar Portillo <nospaze at gmail.com>
> Subject: Re: check, that a script is in a folder
> To: "Community support for Fedora users" <users at lists.fedoraproject.org>
> Date: Wednesday, January 5, 2011, 2:39 PM
> 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
> 
> 
> -- 
> users mailing list
> users at lists.fedoraproject.org
> To unsubscribe or change subscription options:
> https://admin.fedoraproject.org/mailman/listinfo/users
> Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
> 


      


More information about the users mailing list