Bipul Dey
Bipul Dey

Reputation: 11

Make a folder for once in bash

I need a bash script which will find a folder named "Test" in a directory. If it's present there it willn't make the folder named "Test" otherwise it will make a folder named "Test" in the directory. Tried ifs, if, for loop but in vain.

Upvotes: 0

Views: 46

Answers (1)

lollobor
lollobor

Reputation: 26

Here's the code you're probably looking for (pretty basic):

folder="Test"
dir="d"
if [[ !(-e $dir/$folder) ]];then 
mkdir $dir/$folder
fi

-e operator, checks if thats anything as name="Test".

Upvotes: 1

Related Questions