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 3451862
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:11:29+00:00 2026-05-18T09:11:29+00:00

I have 3 directories named: /home/user/control4 , /home/user/control8 ,/home/user/control16 I have written a script

  • 0

I have 3 directories named: /home/user/control4 , /home/user/control8 ,/home/user/control16

I have written a script file which has two loops , the first one is running a simulation, producing 3 files named cc1.txt cc2.txt, and cc3.txt and a second loop is for the names of directory

I like to direct cc1.txt, cc2.txt, cc3.txt to /home/user/control4,/home/user/control8 ,/home/user/control16, respectively. What is the exact syntax for doing this in BASH?

Thanks for your help.

My script file look likes this

#!/user/bin/bash
for j in $(4 8 16 ) # loop for directories
do
for i in $(seq 1 3) # loop for simulations  
do
.... produce cc1.txt cc2.txt cc3.txt 
done

How to output the three files to the respective directories? something like /home/user/control$j/cc$i.txt?

done

  • 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-05-18T09:11:30+00:00Added an answer on May 18, 2026 at 9:11 am
    for j in /home/user/control{4,8,16}
    do
        for i in cc{1,2,3}.txt
        do
            produce "$j/$i"
        done
    done
    

    That will produce nine files. If you want one file per directory for a total of three files, some math might do the trick.

    for i in {1..3}
    do
        produce "/home/user/control$((2*2**i))/cc$i.txt"
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a content folder which is full of other sub-directories named in the
Consider two directories: /home/user/music/flac /media/MUSIC/flac I would like the second directory (destination; a USB
I have a file ( directories.txt ) with directory names, each on a single
I have 2 directories each with a .htaccess file: html/.htaccess - There is a
Background: We have two directories of Crystal Reports for both the web side of
I have a few directories and sub-directories containing files with no file extension. I
Hi I have many directories which have blank space in their names.I have some
I have a list of directories /home /dir1 /dir2 ... /dir100 Some of them
I have the path /home/mine/new that contains files and sub directories. I want to
How can you have model declarations at two different directories in Django? I have

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.