1
我想在我的bash_profile中編寫一個函數來記錄我用來執行程序的一些參數。問題是,當我將參數存儲在一個變量中時,當我調用我的程序時出現錯誤。bash在調用程序時將程序參數存儲在變量中不會工作
#!/bin/bash
para="-db ~/Desktop/search_for_TDS/claClusterSeq -query ~/path/to/file/abc -out ~/Desktop/hallo_blast123"
/home/xyz/blastn $para
這將產生一個錯誤:
Command line argument error: Argument "query". File is not accessible: `~/path/to/file/abc'
雖然這不會:
#!/bin/bash
/home/xyz/blastn -db ~/Desktop/search_for_TDS/claClusterSeq -query ~/path/to/file/abc -out ~/Desktop/hallo_blast123
通過調用在Ubuntu 16.04 LTS bash test.sh
測試執行兩次。
下面是實際的功能,我想在我的.bash_profile如果這是興趣:
blastv25table(){
if [[ ! $# = 5 ]]; then
echo "Param: query db wordSize task evalue"
else
#== Parameters ==
DATE=$(date -I)
para="-num_threads 8
-query $1
-db $2
-outfmt 6
-task $4
-word_size $3
-out $PWD/"$1"_"$4"_ws_"$3"_eval_"$5"_Result_"$DATE"_table
-evalue $5
"
#== Parameter logfile ==
log="./blast_param.log"
echo -e 'Timestamp\t: '$(date)'\nQuery file\t: '$1'\nDB file\t\t: '$2'\nParameters\t: '$para'\nBlastn\t\t: v2.5\n\n##---------------------------##\n' >> $log
#======= Start Blastn ======
/home/xyz/blastn $para
fi
}
,首先導致我的測試是由導致錯誤:
-out $PWD/"$1"_"$4"_ws_"$3"_eval_"$5"_Result_"$DATE"_table
在哪裏想要使用從腳本被調用的目錄用於blastn的輸出參數
謝謝,這個和'-out'行的一個小錯誤的修復做到了。 ''$ PWD/$(basename $ {1})_ $ {4} _ws _ $ {3} _eval _ $ {5} _Result _ $ {date} _table「'basename命令剝離路徑如果我在遠處提供文件 – voiDnyx