Your question remains unclear and probably a duplicate, but I'm guessing it's either of the following. Please follow up in a comment, or edit your question to clarify it still.
Perhaps you are looking for a way to run plink
on each matching file separately?
for file in *_filteredSNPs.txt; do
./plink \
--bfile filesforPRS \
--clump-p1 1 \
--clump-r2 0.1 \
--clump-kb 250 \
--clump "$file" \
--clump-snp-field ID \
--clump-field P \
--out "${file%_filteredSNPs.txt}_clumped"
done
Notice also how double quotes (but not braces {...}
) are necessary to avoid problems when handling files with unusual characters in their names; see When to wrap quotes around a shell variable?
The parameter expansion ${file%_filteredSNPs.txt}
returns the value of the variable with the suffix after %
removed.
This uses no Bash features, and so will work with any sh
variant.
Or, if your plink
command allows more than one --clump
option, and you want to add them all into the same command line, you can just interpolate them into it.
# Put beginning of command into array
cmd=(./plink \
--bfile filesforPRS \
--clump-p1 1 \
--clump-r2 0.1 \
--clump-kb 250)
# Add matches to array
for file in *_filteredSNPs.txt; do
cmd+=(--clump "$file")
done
# Then add tail of command
cmd+=(--clump-snp-field ID \
--clump-field P \
--out "$out")
# Finally, execute it
"${cmd[@]}"
If you have 15 matching files, this will add the --clump
option 15 times, each followed by another one of the 15 file names, then run plink
once.
Arrays are a Bash feature, so this will not work portably with sh
.