The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Difference between writing Unix Shell script and AIX Shell Scripts haroonec AIX 0 04-11-2006 11:27 PM
Need help for writing shell script deepa20 Shell Programming and Scripting 3 02-01-2006 10:23 AM
Need Help Writing Shell Script***please KristenT Shell Programming and Scripting 7 01-31-2006 03:00 PM
Writing a shell Script Chin UNIX for Dummies Questions & Answers 1 06-03-2005 01:32 PM
Need help writing simple script tamdoankc UNIX for Dummies Questions & Answers 1 08-08-2001 04:48 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 03-11-2008
Registered User
 

Join Date: Mar 2008
Posts: 6
HELP! writing simple shell script

how would i write a shell script to show the number of lines in which int variable appears in a c++ program.
Reply With Quote
Forum Sponsor
  #2  
Old 03-11-2008
Tytalus's Avatar
Registered User
 

Join Date: Jun 2003
Location: Scotland
Posts: 286
weeelll

Code:
grep -cw int infile
will tell you how many lines contain at least one int

probably better is something like:

Code:
 tr -cs "[:alpha:]" "[\n*]" < infile | grep -cw int
i.e. create list of words, one per line, then do the count...
Reply With Quote
  #3  
Old 03-11-2008
Registered User
 

Join Date: Mar 2008
Posts: 6
Wink

thanks

but how would i do this using cut or awk methods is it possbile and having a output similar to this

x, number of apperances =
y, number of apperances =
Reply With Quote
  #4  
Old 03-11-2008
Registered User
 

Join Date: Jun 2006
Posts: 164
Quote:
Originally Posted by deadleg View Post
thanks

but how would i do this using cut or awk methods is it possbile and having a output similar to this

x, number of apperances =
y, number of apperances =
I'm not sure if this is what you want, but here's one possible method to get the counts for several different words within a file:

Code:
for W in int float char; do echo $W; egrep "\b$W\b" import.php | wc -l; done
(add a -i after the egrep for case-insensitivity)

ShawnMilo
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:43 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0