Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8410757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:15:43+00:00 2026-06-10T00:15:43+00:00

Im trying to run a UNIX script that will automate the process of creating

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:15:45+00:00Added an answer on June 10, 2026 at 12:15 am

    change your script:

    #!/usr/bin/env bash
    PREFIX=$1
    BEGIN=$2
    END=$3
    for ((i=BEGIN; i<=END; i++))
    do
       DIRNAME=${PREFIX}${i}
       mkdir -p $DIRNAME
       echo created directory with name $DIRNAME
    done
    

    and call it correctly:

    ~/unix_scripts/create_dirs.sh "./courses/CPSC340/Notes/" 9 13
    

    please take care to not overwrite it again as commented below and take time to read: http://tldp.org/LDP/Bash-Beginners-Guide/html/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to update a UNIX shell script to run only if the
I'm trying to run some NUnit tests that use NMock2 for mocking. These tests
I'm trying to create a script that will upload a file to a website.
am trying to run a Java file on Unix machine. Let me show the
I am trying to create a python script which I will later run as
Possible Duplicate: how to use ssh to run shell script on a remote machine?
I'm trying to run the following line of script in bash on Mac OS
I am trying to run some unix commands from my java code. I am
I am trying to run Trac on nginx. There is a simple solution that
In a UNIX-y way, I'm trying to start a process, background it, and tie

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.