How to check that my script can check if it has a specific range of charcters.
Hi so I'm new to scripting and pretty much everything.
I made a script that counts the amount of times a word occurs in a specific file. but now i have to make the script check that the first argument (the word i'm looking to count) is made up of only the specific characters a,c,g,t. and i also have to make my script check that the second argument is a file that contains only a,c,g,t characters in it. if anyone could help that would be awesome!
Hi, welcome to LQ!
In cases such as this it's always best to provide some sample
data - I can't really make too much sense of your description.
Your obviously searching for DNA sequences.
You didn't say, so I'll assume your using bash.
To make sure the file only contains a,c,g, or t
egrep -xv [atcg]+ filename >/dev/null
$RET will be 1 if the file is clean, 0 if it is not.
To check your variable.
echo "$VAR" | egrep -xv [atcg]+ >/dev/null
$RET will be 1 if $VAR is clean, 0 if it is not.
|All times are GMT -5. The time now is 10:14 AM.|