Home Man
Today's Posts

This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

grep help


Thread Tools Search this Thread
# 1  
Old 08-16-2012
grep help

I have a file that contains a number of fasta sequences, each one starts with '>'. I would like to count the number of sequences I have in the file. When I use the code below I get:
$ grep -c '>' total_Protein.txt

even though the file contains hundreds

If I use:
$ grep -c {>} total_Protein.txt 

It doesn't appear to do anything

$ grep -c > total_Protein.txt

Gives me a grep usage error.

Any ideas?
# 2  
Old 08-16-2012
Is it possible that they are all on one (newline separated) record?

What is the result of this command:

awk 'END { print NR-1 }' RS=">"  total_Protein.txt

If not what you are expecting, post a sample of your txt file.
# 3  
Old 08-16-2012
Try this:
grep -o '>' total_Protein.txt | wc -l

The Following User Says Thank You to spacebar For This Useful Post:
jgeahlen (08-18-2012)
# 4  
Old 08-18-2012
Thanks spacebar, worked like a charm!

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` wtolentino Shell Programming and Scripting 6 07-30-2014 05:04 PM
Piping grep into awk, read the next line using grep Paul Moghadam UNIX for Dummies Questions & Answers 2 12-09-2013 11:58 PM
Diff between grep .* file name and grep '.*' filename SasDutta Shell Programming and Scripting 2 11-19-2012 06:13 PM
Bash - CLI - grep - Passing result to grep through pipe jcdole UNIX for Dummies Questions & Answers 1 04-29-2012 06:20 PM
AWK/GREP: grep only lines starting with integer chrisjorg Shell Programming and Scripting 2 04-17-2012 10:06 AM
Advanced grep'in... grep for data next to static element. SysAdm2 UNIX for Dummies Questions & Answers 2 01-05-2011 12:59 PM
grep for certain files using a file as input to grep and then move anita07 Shell Programming and Scripting 2 12-10-2009 03:59 AM
| help | unix | grep (GNU grep) 2.5.1 | advanced regex syntax MykC UNIX for Dummies Questions & Answers 4 10-15-2009 10:52 AM
| help | unix | grep - Can I use grep to return a string with exactly n matches? MykC UNIX for Dummies Questions & Answers 7 10-13-2009 01:57 PM
MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else hariza Shell Programming and Scripting 4 09-18-2008 02:56 AM

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

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
Show Password