".../chr1.fa.gz ..." produced a fasta file with the chr1 sequence concatenated 24 times, I needed to put the variable name in place of the 1 ".../chr1$chr.fa.gz..." to get this to work:
BED=$1
for chr in `seq 1 22` X Y
do
wget -O - -q http://hgdownload.cse.ucsc.edu/goldenPath/hg19/chromosomes/chr$chr.fa.gz | gunzip -c >> hg19.fa
done
fastaFromBed -fi hg19.fa -bed $BED -fo $BED.fasta
(NB - "BED=$1" - bedfile name is first argument passed to script)
How many sequences are you talking? a dozen? thousands? millions? The solution may very well differ depending on your needs.
make sure there is a reason for avoiding to download the genome - I've never seen an analysis that did not need to be repeated many times over and that can quickly backfire and you'll end up with far slower solutions