-1

I need to write a bash script that receives any sequence of nucleotides and print all positions of the T nucleotides.

I did the following:

'vim nucleotide.sh' inside the script

#!/bin/bash
$@
cat $@ | while read line;do echo $line | grep -i t;done

But when I ran the script on new.dat sequence file

$ bash nucleotide.sh new.dat

it displays all sequences without marking T position, however when I run cat $@ | while read line;do echo $line | grep -i t;done outside the script, it displays the sequences with T colored in red. Any suggestions, please

tink
  • 14,342
  • 4
  • 46
  • 50
Eman
  • 15
  • 3

1 Answers1

1

If you want to search for the 't' in the input, you can feed it directly to 'grep', no need to use bash while read ... ; echo ..., or even the cat. You can use grep -h or --no-filename to eliminate file name (in case multiple file names are provided)

grep --color=always -i t -- "$@"
# OR
cat "$@" | grep --color-always -i -t
# OR
grep --color-always -h -i t -- "$@"
dash-o
  • 13,723
  • 1
  • 10
  • 37