[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: check, that a script is in a folder



Hello,

S Mathias a écrit :
> $ 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
> 
> What's wrong with my one-liner?

Two mistakes :
1) "if" expects a command, not a boolean expression. Use "test
<expression>" or "[ <expression> ]" to evaluate the expression.
2) "-eq" is the equal operator for numeric integers, not strings. Use
"=" for string comparison.


Reply to: