![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Awk to count matching IP address | new_buddy | Shell Programming and Scripting | 3 | 05-28-2008 05:24 AM |
| nawk-how count the number of occurances of a pattern, when don't know the pattern | cyber111 | Shell Programming and Scripting | 2 | 05-11-2008 03:00 AM |
| finding duplicate files by size and finding pattern matching and its count | jerome Sukumar | Shell Programming and Scripting | 2 | 12-01-2006 04:20 AM |
| Pattern matching sed | leemjesse | Shell Programming and Scripting | 3 | 03-23-2005 04:06 AM |
| pattern matching | larryase | UNIX for Dummies Questions & Answers | 3 | 11-22-2004 06:54 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
The input is like
NO Code 030019991 22 030087819 0 030089001 22 030178901 39 030333333 22 Patterns i want to match is 0300 0301 0303. i want to count different Codes occurances for each of these pattern. for example for 0300 Code 22 occurs 2 times and 0 occurs 1 time. output should be like that 300: 22 2 0 1 0301: 39 1 etc I have large no of patterns so i have to save them in array and then match them . Please can someone provide with the shell script urgently. |
|
||||
|
Works But
it works fine but matching Patterns may not be 4 digit in lenght that may be 2,5 or 7 etc. Alse file is csv and much more colums may be present between code 22 etc and No 0300... . I will much appreciate your help
|
|
|||||
|
Can you include a sample of the datafile? Perhaps first ten lines or so?
Since you say csv, then you can cut by field rather than character positions - thereby addressing your concern about field length. |
|
||||
|
Another Problem
Quote:
missing ) e:g >>cat abc set a =0; set xyz =(1 2 3 4 5 6); >> chmod 777 abc; >>abc missing parameter ) how can i correct this. I will much appreciate your help. |
|
||||
|
You are not defining 'pattern' - you gave an example of four digits out of eight at the start of a line.
Assuming the first column is a pattern - any combination of digits/letters: Code:
awk '{ arr[$1]++ }
END { for (i in arr) { print i, arr[i]} } ' filename
|
|
||||
|
How to define variables in a file
ok thnk
Last edited by krabu; 10-10-2008 at 03:00 AM.. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| sort, uniq |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|