bash
在ubuntu 14.04
提示用戶輸入,然後在那之後要求文件在select
中使用。但是,我只能選擇其中一個文件,因爲只有1個文件被標記,但目錄中有三個文件。但是,如果我把select
文件放在輸入之前,那麼bash
似乎工作。我似乎無法修復它,什麼是錯的?謝謝。bash進入輸入並選擇文件
擊
# enter gene input
printf "%s \n" "Please enter gene(s), use a comma between multiple:"
OLDIFS=$IFS
IFS=","
read -a genes
for ((i = 0; i < ${#genes[@]}; i++))
do
printf "%s\n" "${genes[$i]}" >> /home/cmccabe/Desktop/NGS/panels/GENE.bed
done
# select file
printf "please select a file to analyze with entered gene or genes \n"
select file in $(cd /home/cmccabe/Desktop/NGS/API/test/bedtools;ls);do break;done
echo $file "will be used to filter reads, identify target bases and genes less than 20 and 30 reads, create a low coverage bed for vizulization, and calculate 20x and 30x coverage for the entered gene(s)"
logfile=/home/cmccabe/Desktop/NGS/API/test/process.log
for file in /home/cmccabe/Desktop/NGS/API/test/bedtools/$file; do
echo "Start selcted file creation: Panel: ${FUNCNAME[0]} Date: $(date) - File: $file"
bname=$(basename $file)
pref=${bname%%.txt}
echo "End selected file creation: $(date) - File: $file"
done >> "$logfile"
在終端
1) 12_newheader_base_counts.txt
34_newheader_base_counts.txt
56_newheader_base_counts.txt
顯示希望的終端顯示
1) 12_newheader_base_counts.txt
2) 34_newheader_base_counts.txt
3) 56_newheader_base_counts.txt
此外,一個好的做法是將您的腳本複製到http://www.shellcheck.net/並修復腳本中所有可能的陷阱。可以節省您的寶貴時間,爲微不足道的問題 – Inian