'Bash error [: missing `]' when checking if file exists
I am getting the error [: missing ]'` when running the below line in bash.
if [ ! -f "$file"]; then
echo "File not found!"
fi
Solution 1:[1]
change
[ ! -f "$file"]
to
[ ! -f "$file" ]
Change summary: added space before ]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tushar |
