to grep and find the count | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

to grep and find the count

UNIX for Dummies Questions & Answers


Tags
grep

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 11-12-2007
arunkumar_mca arunkumar_mca is offline
Registered User
 
Join Date: Oct 2004
Last Activity: 28 October 2014, 9:50 AM EDT
Posts: 286
Thanks: 1
Thanked 1 Time in 1 Post
to grep and find the count

Hi

My files is like

a|test|s|
b|test2 | n|
c|ggg|v|

i want to count the no of lines which is ending with "|" ...
Please let me know how can it be done.

Thanks,
Arun
Sponsored Links
    #2  
Old 11-12-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
 
Join Date: Mar 2005
Last Activity: 5 July 2014, 11:14 AM EDT
Location: classification algos
Posts: 3,203
Thanks: 19
Thanked 30 Times in 27 Posts

Code:
grep -c "|$" filename

Sponsored Links
    #3  
Old 11-12-2007
arunkumar_mca arunkumar_mca is offline
Registered User
 
Join Date: Oct 2004
Last Activity: 28 October 2014, 9:50 AM EDT
Posts: 286
Thanks: 1
Thanked 1 Time in 1 Post
Thanks , Working ...

can you please tell what "|$" $ means ..

Thanks
Aruun
    #4  
Old 11-12-2007
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Advisor  
Full Time Dad
 
Join Date: Sep 2006
Last Activity: 4 April 2014, 3:58 AM EDT
Location: Rossem, Tazenda
Posts: 1,211
Thanks: 6
Thanked 17 Times in 16 Posts
$ indicates end-of-line (and ^ would indicate start-of-line)
-c option of grep tells you the count instead of actual lines
Sponsored Links
    #5  
Old 11-12-2007
arunkumar_mca arunkumar_mca is offline
Registered User
 
Join Date: Oct 2004
Last Activity: 28 October 2014, 9:50 AM EDT
Posts: 286
Thanks: 1
Thanked 1 Time in 1 Post
great explanation thanks ...
Sponsored Links
Closed 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
Help with grep & count in ksh Green_Star UNIX for Dummies Questions & Answers 22 10-07-2011 03:46 PM
grep word count locoroco UNIX for Dummies Questions & Answers 1 05-28-2011 10:00 AM
Sorting using count, grep and count sukhpal_78 UNIX for Dummies Questions & Answers 2 06-27-2008 12:13 AM
count on the grep sudheshnaiyer UNIX for Dummies Questions & Answers 2 08-05-2007 09:11 AM
Grep with count t4st33@mac.com UNIX for Dummies Questions & Answers 3 04-16-2007 10:29 PM



All times are GMT -4. The time now is 08:51 AM.