$ 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
On Wed, Jan 05, 2011 at 02:26:12AM -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 $
So i just want to check that i'm in an exact folder. e.g.: "asdf"
What's wrong with my one-liner?
What's wrong is you can't read man pages or research on your own. "man bash"; your problem is covered there.
John
On 1/5/11 4:42 AM, John R. Dennison wrote:
On Wed, Jan 05, 2011 at 02:26:12AM -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 $
So i just want to check that i'm in an exact folder. e.g.: "asdf"
What's wrong with my one-liner?
What's wrong is you can't read man pages or research on your own. "man bash"; your problem is covered there.
It is there, but it's pretty obscure. A hint is that 'if' wants to execute something, and in the old days /bin/test and /bin/[ used to be links to the same executable. These days the executables are in /usr/bin and not linked (don't know the reason for either...) but they are also shell builtins.
Les Mikesell wrote:
John R. Dennison wrote:
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?
What's wrong is you can't read man pages or research on your own. "man bash"; your problem is covered there.
It is there, but it's pretty obscure. A hint is that 'if' wants to execute something, and in the old days /bin/test and /bin/[ used to be links to the same executable. These days the executables are in /usr/bin and not linked (don't know the reason for either...) but they are also shell builtins.
The Usenet newsgroup comp.unix.shell is a great place to ask such questions.