I need to understand bash if expressions. Sure, I've used Google. I know that it goes something like this:
if [ expr operator expr ]
then
doSomeThing
fi
However, I understand that Bash doesn't have a boolean data type. I want to check if the file passed as an argument ($1) exists. The way I would do this straight of my mind:
if [ -e $1 = true ]
then
echo "File exists."
fḯ
Or maybe like:
if [ -e $1 ] #Assuming that this is true only if file in $1 exists.
None of these work, and I'm not sure what [ ] means. -e $1 seems like a smart choice, but it is always true? There are different operators for strings and integers. And I can't use parenthesis to group together expressions. This is so confusing.
Anyone got a few hints? The IF in bash does not work like if I've tried in any other language.