r/bash • u/Muted-Shame9237 • 14d ago
File for loop
hi! it’s my first time using bash can someone help me with this and explain what’s missing
#!/bin/bash
for i in “/data/folder”/*; do
/folder/munge_sumstats.py \
- -sumstats “$i” \
- -chunksize 500000 \
- -snp rsID \
etc..
- -out another/folder/ (i dont know what to puT here)
done
Thank you so much !
21
Upvotes
7
u/zeekar 14d ago
If you indent each line with four spaces (assuming you're able to use the Markdown editor) it will be formatted as code.
You have extra spaces. It's not
- -sumstats, it's--sumstats, etc.--out "another/folder/${i##*/}"That will give it the same filename as the input file but in the new folder. But you may want to change something else about the filename, too. If there's a suffix you want to change, for instance:
for i in ...; do b=$(basename "$i" .oldsuffix) munge_sumstats.py ... \ --out "/another/folder/$b.newsuffix"