I am very new with linux shell commands. I need to read a text file which contains several lines as '!Platform_series_id = GSE1145'. I should split each line to use 'GSE1145' after the '=' sign part of it. Finally I want to produce a link such as 'ftp://ftp.ncbi.nlm.nih.gov/geo/series/GSE5nnn/GSE1145/suppl/GSE1145_RAW.tar' The bold parts of the link will be taken from the txt file. The remaining parts are constant. This was the story.
If I come to the point where I got stuck:
When I run the following code
while read p; do A="$(cut -d'=' -f2 <<<$p)" echo "ftp://ftp.ncbi.nlm.nih.gov/geo/series/GSE5nnn/$A/suppl/$A_RAW.tar" done < a.txt
It gives an unexpected result
/suppl/.tarcbi.nlm.nih.gov/geo/series/GSE5nnn/ GSE1145 /suppl/.tarcbi.nlm.nih.gov/geo/series/GSE5nnn/ GSE1643
Then I tried simply concatenating the same variable
while read p; do A="$(cut -d'=' -f2 <<<$p)" echo "$A$A" done < a.txt
But still the answer is not what I expect. It just behaves as it is written echo $A.
To understand the problem, finally I tried the following code:
A="$(cut -d'=' -f2 <<< '!Platform_series_id = GSE1145')" echo $A$A
It gives me a correct result
So what is the problem when I read it?
By the way, when I try following code, It works! But why? I think this is not the correct way. If I put spaces as many as the length of the $A,
while read p; do A="$(cut -d'=' -f2 <<<$p)" echo " $A$A" done < a.txt
GSE1145 GSE1145 GSE1643 GSE1643
Thanks for helps.