So I want to use grep with variables I'd be picking from a text file (one per line). I've tried different commands for grep and it's not working... I've seen also similar questions, but anything seems to be working? Any help would be much appreciated, thanks. Below my attempt, manually assigning the variable hey grep works, but not if I attempt to take the variable from the ids.txt file
Thank you very much!
$ head ids.txt
Nitab4.5_0005105
Nitab4.5_0007510
Nitab4.5_0001604
$ for i in $(cat ids.txt); do grep -A1 "$i" seqs.fasta; done
$ hey="Nitab4.5_0001604"
$ grep -A1 "$hey" seqs.fasta
>Nitab4.5_0001604
ATGTCATGCATTTTTTAAAANNNNNNNNNNNA
seqs.fastafile that you're grepping from. I also suggest to addechoto the beginng of yourgrepcommand in your loop, to ensure the command actually looks the way you think it does. And last thing, please run the following command:head ids.txt | cat -Ato check if there are any imvisible escape characters as @KamilMaciorowski suggested. – aviro Feb 28 '22 at 08:33grepcan read patterns from a file:grep -f ids.txt seqs.fasta. Also note, that.is a special character for regex pattern. You might want to use-Fto advicegrepto use a fixed string instead. – pLumo Feb 28 '22 at 10:52