I'm having an issue getting the variables $myname, $filename, and a method that counts all the records in another file, wc -l < hs_alt_HuRef_chr10.fa >> "$CuestaP.txt, to append to the text file CuestaP.txt. Code is below I don't see why they aren't appending.
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
My output: Hello my name is: 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?
CuestaPcontains the correct value? Perhaps the strings get appended to a different file than you expect. Do aset -xbefore appending the strings.