変数を取得し、$myname
他のファイルのすべてのレコードを計算してテキストファイルに追加する方法に$filename
問題があります。コードは以下にありますが、なぜ添付されないのかわかりません。wc -l < hs_alt_HuRef_chr10.fa >> "$CuestaP.txt
CuestaP.txt
myname="Pablo Andres Cuesta" #creates variable containing my name
echo "Hello my name is:"
echo "$myname" #Display myname
echo
echo "This program is called:"
filename=$(basename "$0") #Display name of file without ./
echo "$filename"
echo
echo "$myname" >> "$CuestaP.txt" #Puts myname inside text file
echo "$filename" >> "$CuestaP.txt" # Puts file name inside text file
echo "The number of records inside the file 'hs_alt_HuRef_chr10' are:"
wc -l < hs_alt_HuRef_chr10.fa
wc -l < hs_alt_HuRef_chr10.fa >> "$CuestaP.txt" #Put amount of records inside file
echo "$USER" >> "$CuestaP.txt" #Add username to text file
echo "$PWD" >> "$CuestaP.txt" #Add file location to text file
if [ -s *.fa ]; then
# read the age from the file.
# if the file exists and is not empty, see flags above
echo "my *.fa file exists and has data in it" >>
"$CuestaP.txt"
else
echo "THIS DID NOT WORK CORRECTLY" >> "$CuestaP.txt"
fi
echo
cat CuestaP.txt
私の結果:こんにちは。私の名前はPablo Andres Cuestaです。
This program is called:
CuestaPOGpgm3.sh
The number of records inside the file 'hs_alt_HuRef_chr10' are:
1842651
#myname is missing
#filename is missing
#my *.fa file exists and has data in it is missing
pcuesta #my username went through though?
/home/pcuesta #my pwd went through though?
ベストアンサー1
問題はファイル名です$CuestaP.txt
。$
実際にファイル名の一部になるには、単一引用符またはバックスラッシュ('$CuestaP.txt'
、)が必要です\$CuestaP.txt
。あるいは、これは変数と見なされましたが、すべてを定義することを忘れて、リテラルと混合しました。
あなたのデータはファイルにあります.txt