Directory

Directory Commands

Making directory

mkdir directory_name

Make multi level directory

If you want to create directories throughout the whole PATH then you would have to use flag -p

mkdir -p $HOME/Downloads/Projects2/Internal_Project/Dependency

This will create all the folders/directories necessary till the last folder.

mkdir and cd

Copy directory

cp -r source_directory_path destination_directory_path

Linux Handbook

Rename directory

Use move command to rename a directory.

mv SensehackMedia SensehackMedia2

Deletion Directories

Deleting directories using rm -rf commands

remove directory

Remove dir

Check directory exists

# Checking directories and deciding different paths.
case $PWD/ in
	*/Custom-iOS/Custom-iOS/*)
		echo "🚀🚀🚀"
		. ..ops/dir/script ;;
	*/Custom-iOS/*)
		echo "In previous directory"
		. ops/dir/script ;;
	*)
		echo "❌❌❌ Couldn't find the 'script'. \n Please manually run the setup script! " ;; # default case
esac

SO

Check file exists

If then else approach
Check for git repository being initialized and depending on the condition clone or skip this command.

FILE_README=Custom-App/README.md
FILE_GIT=Custom-App/.gitmodules
if [! [ -f $FILE_GIT || -f $FILE_README ]]; then
    echo "Custom-App Main Git Repository already exists."
else 
	echo "Cloning the repository... \nPlease enter your credentials 🔑"
	git clone git@gitlab.com:domain/mobile/Custom-App.git
	cd Custom-App
fi

file exists

Loop in directory

We can check for every file or directory in the $PWD & this could be helpful for making automation scripts on a number of files.

SO