我有一個問題如何將變量字符串傳遞給測試biginig中的文件txt?
我有一個程序一般是這樣gene.sh
,對於所有文件(ES文件:geneX.csv)使與基因的名稱(例如目錄:GENEX/GENEX .csv)接下來這個程序在gene.sh內編譯一個其他程序,但是這個程序需要一個varieble,我不知道它是如何做到的。
這是程序gene.sh
#!/bin/bash
# Create a dictory for each file *.xls and *.csv
for fname in *.xlsx *csv
do
dname=${fname%.*}
[[ -d $dname ]] || mkdir "$dname"
mv "$fname" "$dname"
done
# For each gene go inside the directory and compile the programs getChromosomicPositions.sh to have the positions, and getHapolotipeStings.sh to have the variants
for geni in */; do
cd $geni
z=$(tail -n 1 *.csv | tr ';' "\n" | wc -l)
cd ..
cp getChromosomicPositions.sh $geni --->
cp getHaplotypeStrings.sh $geni
cd $geni
export z
./getChromosomicPositions.sh *.csv
export z
./getHaplotypeStrings.sh *.csv
cd ..
done
這是程序getChromosomichPositions.sh:
rm chrPosRs.txt
grep '^Haplotype\ ID' $1 | cut -d ";" -f 4-61 | tr ";" "\n" | awk '{print "select chrom,chromStart,chromEnd,name from snp147 where name=\""$1"\";"}' > listOfQuery.txt
while read l; do
echo $l > query.txt
mysql -h genome-mysql.cse.ucsc.edu -u genome -A -D hg38 --skip-column-names <query.txt> queryResult.txt
if [[ "$(cat queryResult.txt)" == "" ]];
then
cat query.txt |
while read line; do
echo $line | awk '$6 ~/rs/ {print $6}' > temp.txt;
if [[ "$(cat temp.txt)" != "" ]];
then cat temp.txt | awk -F'name="' '{print $2}' | sed -e 's/";//g' > temp.txt;
./getHGSVposHG19.sh temp.txt ---> Hear the problem--->
else
echo $line | awk '{num=sub(/.*:g\./,"");num+=sub(/\".*/,"");if(num==2){print};num=""}' > temp2.txt
fi
done
cat query.txt >> varianti.txt
echo "Missing Data" >> chrPosRs.txt
else
cat queryResult.txt >> chrPosRs.txt
fi
done < listOfQuery.txt
rm query*
聽到這個問題:
我需要在文件中臨時進入。 txt並自動在文件的開頭放置程序基因的變量$ geni.sh
我該怎麼做?
例如在TEMP.TXT有: 35941G>甲 我通過變量$ GENI慣於(例如:GENI = 「CBA1」)更改文件TEMP.TXT中: CBA1:35941G>甲 –
你不能編輯你的問題而不是評論它嗎?當你處理它時,你可以修改格式,特別是'!#/ bin/bash'行。 \ [編輯]你在我寫作的時候糾正了這條線。 –