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
Search for a word on9west Shell Programming and Scripting 2 04-23-2008 04:15 AM
to get a line above the search word sachin.gangadha UNIX for Dummies Questions & Answers 16 01-07-2008 07:19 AM
String search - Command to find second occurance saurabhsinha23 UNIX for Dummies Questions & Answers 5 12-06-2007 08:03 PM
Word search in awk videsh77 Shell Programming and Scripting 8 03-08-2007 11:40 PM
Search about word abu_hassan SUN Solaris 3 02-19-2007 01:17 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-05-2008
legendofanatoli legendofanatoli is offline
Registered User
  
 

Join Date: May 2008
Posts: 2
search for a word and learn number of occurance of that word

hey to everybody
this is my first post at this forum
I need a very immediate answer for this question. If you can, I will be delightfull

I have a file called example.txt and I want to seek for the for hello and learn the number of the occurance of hello

Last edited by legendofanatoli; 05-05-2008 at 05:04 PM..
  #2 (permalink)  
Old 05-05-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,813
if hello can occur only one time in a line of text:

Code:
grep -c 'hello' example.txt

otherwise

Code:
#!/bin/ksh
wc -l example.txt | read start dummy
sed 's/hello//g' example.txt | wc -c read  end
count=$(  (start - end ) /5 )
echo $count

  #3 (permalink)  
Old 05-05-2008
legendofanatoli legendofanatoli is offline
Registered User
  
 

Join Date: May 2008
Posts: 2
thx a lot my friend
it's working
Closed Thread

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 On




All times are GMT -4. The time now is 07:23 AM.


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