I want to pass directory name as the function's parameter and then check whether it exists or not. Here's what I got:
#!/bin/bash
my_function() {
dir="$1"
if [ -d dir ]; then
cd dir
else
mkdir dir
fi
}