** Combining the -e option with an if statement **
If "If the file already exists, I want to execute it."
#!/bin/bash
filename=hoge
if [ -e $filename];then
echo "$filename exists"
fi
If you say, "If the file already exists, there is nothing extra to do." ** If you want negative logic, add! Before -e **
#!/bin/bash
filename=hoge
if [ !-e $filename];then
mkdir $filename
that's all
Recommended Posts