![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem with GREP. | syndex | Shell Programming and Scripting | 2 | 07-11-2007 10:44 AM |
| grep problem | asal_email2 | UNIX for Dummies Questions & Answers | 4 | 06-22-2005 05:49 PM |
| grep problem | svennie | UNIX for Dummies Questions & Answers | 5 | 11-08-2004 01:29 AM |
| Grep Problem | lesstjm | Shell Programming and Scripting | 2 | 10-27-2004 07:13 AM |
| Grep problem | odogbolu98 | Shell Programming and Scripting | 3 | 02-18-2003 12:53 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Code:
cat *:22:B0 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
what is wrong? |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
wouldn't it be easier to do it all in awk?
Code:
nawk '{arr[$2]++} END {for (i in arr) printf("pattern->[%s] numOFoccur->[%d]\n", i, arr[i])}' *:22:B0
|
|
#3
|
||||
|
||||
|
thanks
thanks you very much.
|
||||
| Google The UNIX and Linux Forums |