LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 09-30-2010, 11:04 PM   #1
shirlcurl20
LQ Newbie
 
Registered: Sep 2010
Posts: 1

Rep: Reputation: 0
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!
 
Old 10-01-2010, 12:09 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.


Cheers,
Tink
 
Old 11-17-2010, 12:15 AM   #3
rustek
Member
 
Registered: Jan 2010
Location: Melbourne, IA, USA
Distribution: Ubuntu
Posts: 93

Rep: Reputation: 8
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=$?

$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=$?

$RET will be 1 if $VAR is clean, 0 if it is not.

Last edited by rustek; 11-17-2010 at 12:19 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A script to check ports of a long range of IPs tirengarfio Linux - Networking 3 07-06-2009 11:48 AM
Check It ??Squid ACLS to Block Files for Specific Domain and to Spefic IP farrukhndm Linux - Server 0 12-06-2008 01:41 AM
Check if an int value is within valid range of enum? mic Programming 6 02-21-2006 12:02 PM
Partition check, check double check Vincentius Linux - General 0 12-25-2004 06:47 AM
Boot disk; check. CD in drive; check. Doesn't work; check. Hal DamnSmallLinux 7 02-04-2004 03:10 AM


All times are GMT -5. The time now is 09:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration