IYKYK made for a performance task activity in a major subject, published for syntax highlighting part
labs-gradeops.sh
34 lines 756 B view raw
1#!/usr/bin/env bash 2# SPDX-License-Identifier: MIT 3# Author: Andrei Jiroh Halili (STI College Meycauayan) <halili.459491@meycauayan.sti.edu.ph> 4set -e 5 6if [[ $DEBUG != "" ]]; then 7 set -x 8fi 9 10checkIfExistsAndMkdir() { 11 if [ $1 == "" ]; then 12 echo "Usage: checkIfExistsAndMkdir /path/to/dir" 13 return 1 14 fi 15 16 if [ -d $1 ]; then 17 echo "directory '$1' exists, skipping mkdir" 18 else 19 mkdir -pv "$1" 20 fi 21} 22 23echo "Welcome aboard!" 24 25read -p "What's your name? " name 26name_dir="$(pwd)/${name}" 27checkIfExistsAndMkdir "$name_dir" 28 29read -p "What's your subject name? " subject 30subject_dir="${name_dir}/${subject}" 31checkIfExistsAndMkdir "$subject_dir" 32touch "$subject_dir/grades.dat" && chmod 755 "$subject_dir/grades.dat" 33 34echo "Setup flow completed"