Skip to primary content

Phaisarn

Phaisarn

Main menu

  • Home

Post navigation

← Previous Next →

Create directory if a directory does not already exist

Posted on February 7, 2023 by jack
  • shell – How to mkdir only if a directory does not already exist? – Stack Overflow

สร้าง directory ชื่อ log

#!/bin/bash

dir=log
if [ ! -d $dir ]
then
  mkdir $dir
  echo "create directory $dir"
else
  echo "Directory exists"
fi
This entry was posted in Linux Command by jack. Bookmark the permalink.
Proudly powered by WordPress