this is a recurrent topic but still not duplicate since I tried all the solutions and none worked for me.
I am trying to add the suffix "_1" to a list of identifiers imported from a txt file. The goal is to add this into a loop in a function.
GSE72343.txt:
SRR2182285
SRR2182286
SRR2182287
SRR2182288
SRR2182289
and I want to retrieve this:
SRR2182285_1
SRR2182286_1
SRR2182287_1
SRR2182288_1
SRR2182289_1
I've tried a couple of suggestions in other threads here and here but I am getting wrong outputs like showed below:
for i in $(cat GSE72343.txt); do echo "$i" "$i_1"; done
RR2182285
RR2182286
RR2182287
RR2182288
RR2182289
sed 's/$/ _1/' GSE72343.txt
_12182285
_12182286
_12182287
_12182288
_12182289
awk '{ print $0, "_1" }' GSE72343.txt
_12182285
_12182286
_12182287
_12182288
_12182289
Any advices? Thanks a lot!
{}
around your variable.for i in $(cat GSE72343.txt); do echo "$i" "${i}_1"; done
The way you have it currently, it is trying to reference the variable i_1, when really you want to reference the variable i and tack on _1 to the end of it. Using curly brackets in quotes allows you to do this.
– Natolio Apr 07 '21 at 18:42