LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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, 10: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 09-30-2010, 11:09 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,986
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
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-16-2010, 11:15 PM   #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-16-2010 at 11:19 PM.
 
  


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 10:48 AM
Check It ??Squid ACLS to Block Files for Specific Domain and to Spefic IP farrukhndm Linux - Server 0 12-06-2008 12:41 AM
Check if an int value is within valid range of enum? mic Programming 6 02-21-2006 11:02 AM
Partition check, check double check Vincentius Linux - General 0 12-25-2004 05:47 AM
Boot disk; check. CD in drive; check. Doesn't work; check. Hal DamnSmallLinux 7 02-04-2004 02:10 AM


All times are GMT -5. The time now is 12:31 AM.

Main Menu
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