Skip to content
Advertisement

Linux: Loop using foldername when finding file

I’m currently trying to use the following linux script to loop through folders and perform calculations using a function:

JavaScript

The problem: How can I use the foldername to find the correct file? For example, the foldername is scan1 and I want to use the file called gaf_scan1_recording_mic.nii for the function.

Thanks a lot,

Eric

Advertisement

Answer

In most cases, $var and ${var} are the same (the braces are only needed for ambiguity in the expressions):

JavaScript

You can use the folder name like this (gaf_${f}_recording_mic.nii):

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement