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?

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .