1

I am super fresh in the bash language and I am missing several key concepts. Please excuse my ignorance.

My structure is

folder A
   |--- folderB1q/output/output.csv
   |--- folderB2q/output/output.csv
   |--- ...
   |--- folderB100q/output/output.csv

I want to read in bash from folder A each output.csv file and apply a function on it. I have tested my function and it works when I go to the directory of the file. I have thousands of directories though...

for each in *q/output/ 
do
my function .......
done

Thank you for your time and sorry for my bad coding

1 Answer 1

2

each output.csv

Then loop over output.csv files.

for each in */output/output.csv
do
    my function "$each"
done

I have thousands of directories though...

With many directories, using a shell loop might be memory expensive, because shell. Use a find.

find . -type f -mindepth 3 -maxdepth 3 -path '.*/output/output.csv' |
xargs -d'\n' -n1 my_command
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.