Reputation: 327
I am trying to write a bash script to do a batch processing of some fMRI data. My problem is that I am not able to get the filenames that match a specific pattern within the directory of interest.
My scripts looks like this
#!/bin/bash
inputpath="/Volumes/External_HD/Experiments/MRI_Data"
outputpath="/Volumes/External_HD/Experiments/MRI_Data_output"
anatomical_scans=$find `$inputpath` -name *mprage
# RUN BET
bet $anatomical_scans $outputpath
echo 'Finished!!!'
The only output that I get is the following error message
-name: command not found
I am definetely not familiar with shell scripting so I am sorry if the question may sound trivial. Any help will be much appreciated.
Antonio
EDIT:: SOLVED
Exploring the suggestions I found the correct way to make it running with no errors
anatomical_scans=$(find $input_path -name "*mprage*")
Thanks
Upvotes: 1
Views: 157
Reputation: 1309
try changing the line
anatomical_scans=$find
$inputpath-name *mprage
to
anatomical_scans=$(find "${inputpath}" -name "*mprage")
Upvotes: 4
Reputation: 471
You can try as below, hope it can help.
#!/bin/bash
inputpath="/Volumes/External_HD/Experiments/MRI_Data"
outputpath="/Volumes/External_HD/Experiments/MRI_Data_output"
anatomical_scans=`find $inputpath -name '*mprage'`
# RUN BET
bet $anatomical_scans $outputpath
echo 'Finished!!!'
Upvotes: 1
Reputation: 659
You can do the following:
#!/bin/bash
inputpath="/Volumes/External_HD/Experiments/MRI_Data"
outputpath="/Volumes/External_HD/Experiments/MRI_Data_output"
function anatomical_scans {
find $inputpath -name "*mprage"
}
# RUN BET
bet anatomical_scans $outputpath
echo "Finished!!!"
Upvotes: 1