Im trying to run a UNIX script that will automate the process of creating directories. am running the bash shell on my machine
These are the steps I followed
1) Created a directory on my mac: ~/unix_scripts
2) Created a file: ~/unix_scripts/create_dirs.sh
#! /usr/bin/env bash
for ((i = 9; i<= 13; i++ ))
do
mkdir ./courses/CPSC340/Notes/$i
echo created directory with name $i
done
3) Changed the file permissions of this file using this command: chmod +x create_dirs.sh
4) tried to run this file using this command: ~/unix_scripts >create_dirs.sh
I got this error:
-bash: ./unix_scripts/create_dirs: No such file or directory
I have the following questions about this:
1) What am I doing wrong ? How can I get this thing to work?
2) Once it is working, How can I modify the script such that
- I can pass the beginning index and end index as arguments to the script
- I would like to also pass a prefix as a command line argument so that the directories are named ""prefix_ + (value of i)"
Many thanks for your help
change your script:
and call it correctly:
please take care to not overwrite it again as commented below and take time to read: http://tldp.org/LDP/Bash-Beginners-Guide/html/