The UNIX and Linux Forums  

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



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Count number of occurences of a word shikhakaul UNIX for Dummies Questions & Answers 8 06-25-2009 12:10 PM
count occurences of specific character in the file superprogrammer HP-UX 9 04-09-2008 12:05 PM
grep all records in a file and get a word count -perl meghana Shell Programming and Scripting 4 02-13-2008 10:06 PM
How to print all lines that has exactly 3 occurences of digit 4 using grep? sivasai83 Shell Programming and Scripting 3 01-31-2007 02:21 AM
How to count no of occurences of a character in a string in UNIX kamesh83 UNIX for Advanced & Expert Users 11 03-17-2006 02:39 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 04-20-2007
srikanthgr1 srikanthgr1 is offline
Registered User
  
 

Join Date: Apr 2007
Location: Bangalore
Posts: 17
Question grep and count no of occurences in every line of a file

Hi Folks,

I have a input file of the below format.


~~~OLKIT~OLKIT~1~~TBD~BEST PAGER & WIRELESS~4899 COMMON MARKET PLACE~~~DUBLIN~KS~43016~I~Y~DIRECT~D~~0
BPGRWRLS~~~OLKIT~OLKIT~1~~TBD~BEST PAGER & WIRELESS~4899 COMMON MARKET PLACE~~~DUBLIN~KS~43016~I~Y~DIRECT~D~~0
BPI~~~OLKIT~OLKIT~1~~TBD~CITI CONNECTION~6413 18TH AVE~~~BROOKLYN~KS~11204~~Y~DIRECT~D~~0
BPNABOF~~~OLKIT~OLKIT~1~~TBD~BRIGHTPOINT NORTH AMERICA~501 AIRTECH PARKWAY~~~PLAINFIELD~KS~46168~~Y~DIRECT~DT~~0
BRADSINC~~~OLKIT~OLKIT~1~~TBD~BRADSHAW INC~4662 HORN LAKE RD~~~MEMPHIS~KS~38109~I~Y~DIRECT~D~~0
BWRES07TM~~~OLKIT~OLKIT~1~~TBD~BLUEFISH WIRELESS INC.~6100 WEST 96TH ST., SUITE 140~~~INDIANAPOLIS~KS~46278~~Y~DIRECT~J~~0
BYFGRPTM~~~OLKIT~OLKIT~1~~TBD~BYF GROUP, INC.~4810 BEAUREGARD ST.~~~ALEXANDRIA~KS~22312~~Y~DIRECT~F~~0



In the input file I have many no of lines which have "~" symbols in them.
In every line, I need to count the no. of times "~" occurs and compare it with a variable which is passed along with the shell script in the command line.

I have highlited each line in diffn color.

The command line format is
shell_script input_file.dat 20

In the above line 20 is the no to which the no of "~" are compared

Help is very much required as I am very new into shell scripting.


Regards
Srikanth GR

Last edited by srikanthgr1; 04-20-2007 at 06:30 AM.. Reason: Needed to give more details.
 

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 02:03 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