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
Problem with GREP. syndex Shell Programming and Scripting 2 07-11-2007 02:44 PM
grep problem asal_email2 UNIX for Dummies Questions & Answers 4 06-22-2005 09:49 PM
grep problem svennie UNIX for Dummies Questions & Answers 5 11-08-2004 04:29 AM
Grep Problem lesstjm Shell Programming and Scripting 2 10-27-2004 11:13 AM
Grep problem odogbolu98 Shell Programming and Scripting 3 02-18-2003 03:53 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 11-09-2006
yogesh_powar's Avatar
yogesh_powar yogesh_powar is offline
Registered User
  
 

Join Date: Jun 2005
Location: satara
Posts: 37
Question grep problem


Code:
cat *:22:B0

has the following output

Code:
2220 -50
2220 -50
2220 -51
2225 -47
2225 -50
2230 -63
2230 -50
2235 -50
2235 -50
2235 -48
2240 -53
2240 -53
2245 -51
2245 -51
2250 -52
2250 -52
2250 -50


Code:
#!/bin/bash

#All unique numbers from file *:22:B0 will be in /tmp/uni
cat *:22:B0|awk  '{print $2}'|sort -nu>>/tmp/uni


# max will number of unique numbers
max=wc -l /tmp/uni |awk '{print $1}'

for((i=1;i<$max;i++))
        do

# pattern will have each unique number
    pattern=`cat /tmp/uni|head -$i|tail -1`


#Following code should find out how many occurance of pattern are there in *:22:B0
        cat *:22:B0|grep $pattern|wc -l


        done

There is some syntax wrong in last line.
what is wrong?
 

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 05:48 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