Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 09-30-2010, 10:04 PM   #1
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
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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

Old 11-16-2010, 11:15 PM   #3
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 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.

Last edited by rustek; 11-16-2010 at 11:19 PM.


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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:06 AM.

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