The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
grep unix.com with google



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #8 (permalink)  
Old 11-14-2009
Registered User
 

Join Date: Oct 2009
Location: St. Louis, MO
Posts: 78
I see... I think.... A sequence includes all the lines between the headers?
Bits Awarded / Charged to jsmithstl for this Post
Date User Comment Amount
11-15-2009 abacus Thank you for your assistance... 10,000
  #9 (permalink)  
Old 11-14-2009
abacus's Avatar
Registered User
 

Join Date: Oct 2009
Location: 41.332032,-73.089775
Posts: 27
Yes,

I think he just needs a count of the sequences that do not contain the letter J. It seems a bit more simpler now.

So a script to read in each sequence and print how many sequences with the letter J.

The example is 1. Due to 1 J sequence.

THanks again for your time and assistance.

Abacus
  #10 (permalink)  
Old 11-14-2009
Registered User
 

Join Date: Nov 2008
Location: Amsterdam
Posts: 1,258
Something like this then?

Code:
awk '/^>/{if(s==1)t++;s=1;next} /J/{s=0} END{if(s==1)t++;print "J-less sequences: "t}' infile

Bits Awarded / Charged to Scrutinizer for this Post
Date User Comment Amount
11-15-2009 abacus Thank you for your time and expertise.... 10,000
  #11 (permalink)  
Old 11-15-2009
abacus's Avatar
Registered User
 

Join Date: Oct 2009
Location: 41.332032,-73.089775
Posts: 27
Hmm,
OSX Snow Leopard tested.



Code:
machine1:~ jasonralph$ awk '/^>/{if(s==1)t++;s=1;next} /J/{s=0} END{if(s==1)t++;print "J-less sequences: "t}' infile
J-less sequences: 
c-machine1:~ jasonralph$

Thans for your time as always.

Abacus
  #12 (permalink)  
Old 11-15-2009
ahmad.diab's Avatar
Registered User
 

Join Date: May 2008
Location: Amman Jordan in MEA
Posts: 416
you can know the number of sequences that have J on it on each description, then you can grep the zero or write if condition grep the "0" values counter.

Code:-


Code:
gawk '
/^>/{ t=$0 ; a[t]=0 ;next}
/J/{a[t]++  }
END{ for ( i in a ) { printf "J exist in %s sequence(s) of header %s\n",a[i],i } }
'  input_file




Code:
Output

J exist in 2 sequence(s) of header >description 1-blah blah blah
J exist in 1 sequence(s) of header >description 2-blah blah blah


Bits Awarded / Charged to ahmad.diab for this Post
Date User Comment Amount
11-15-2009 abacus Thank You Sir, 10,000
  #13 (permalink)  
Old 11-15-2009
abacus's Avatar
Registered User
 

Join Date: Oct 2009
Location: 41.332032,-73.089775
Posts: 27
[solved]

Thanks to ahmad.diab, scruitinizer and jsmithstl. The code examples that you have all provided have done the trick.

My friend and I are very satisfied with the level of professionalism found on this site by the users.

Abacus
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
An urgent assistance kinny Shell Programming and Scripting 5 10-30-2009 07:08 AM
rsync assistance SteveMosher UNIX for Advanced & Expert Users 4 09-21-2009 02:48 PM
I need an assistance mytilini boy Shell Programming and Scripting 1 05-25-2007 09:42 PM
Need Assistance yahoo14 UNIX for Dummies Questions & Answers 1 06-08-2006 11:21 AM



All times are GMT -4. The time now is 01:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0