1

I'm running simulations and I need to make figures.

I have a script to make these, but I don't want to copy it to each subfolder manually. (e.g. I have an X folder containing XA, XB,.... XZ, and XA, XB,... XZ each have another 12 folders in it which all contain the results of my simulations)

I want to write a bash script which can go to each subfolder and execute my figure-making command.

How can I do it?

3

This should be able to write to sub folders in main directory of interest:  

#!/bin/bash   

for i in /path/to/directory/X/*/*; 
do 
    echo "hi" > "$i"/t.txt
done

Scenario:

X/
├── XA
│   └── subsub1
│       └── t.txt
├── XB
│   └── subsub2
│       └── t.txt
└── XC
    └── subsub3
        └── t.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.