I want to check if a file exists by using a if comparison for a base path concatenated with a file name. I'm trying things like:
declare -r BasePath="/some/path"
if [ -f "$BasePath" "/my_file.txt" ]
then
#do something
fi
I just can't get the concatenation of the variable holding the base path with the string literal to work within the comparison.
CodePudding user response:
Just:
if [ -f "$BasePath/my_file.txt" ]