I'm writing a script and need for cd
to iterate through a bunch of subdirectories but I can't get the shell to commit to the cd
, much less execute the rest of the script properly. I've pored over similar questions but none of them have answered me properly -- making a function and sourcing the script hasn't worked. I'm still relatively new to the terminal and I'm very lost right now.
#!/bin/bash
. ./exptime.sh #without a #, this yields a segmentation fault
function exptime() {
#make an array of directories
filedir=( $(find ~/Documents/Images -maxdepth 1 -type d) )
alias cdall 'cd ${filedir[*]}' #terminal has trouble recognizing the alias
for filedirs in ${filedir[*]}
do
cdall
ftlist "fuv.fits[1]" T column=3 rows=1 | grep "[0-9]" |
awk '{print $2}' > fuv_exptime #recognizes this command but
# can't execute properly because it's in the wrong directory
done