![]() |
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 |
| count the max by awk | halola85 | Shell Programming and Scripting | 9 | 12-01-2008 07:44 AM |
| replaying a record count with another record count | er_zeeshan05 | Shell Programming and Scripting | 2 | 10-30-2008 12:14 AM |
| Sorting using count, grep and count | sukhpal_78 | UNIX for Dummies Questions & Answers | 2 | 06-27-2008 01:13 AM |
| How to count the record count in an EBCDIC file. | oracle8 | UNIX for Dummies Questions & Answers | 1 | 07-26-2006 08:22 PM |
| CPU count | hshapiro | UNIX for Dummies Questions & Answers | 2 | 04-03-2006 02:08 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Need Help to count the deployments
Hi,
Need help for a script that count no of deployments from the below Sample Input file. Below is my sample input file. Not sure whether it works or not. Note: (We can use a seperator if needed) My output should come like for each Store: Output should look like: Store_MS1: 4 Deployments Store_MS2: 3 Deployments --MS3 ..MS8: 1 Deployment __________________________________ Sample Input file: __________________________________ Successfully connected to Admin Server 'Store_Adm' that belongs to domain 'Store_CITY_XXX'. Warning: An insecure protocol was used to connect to the server. To ensure on-the-wire security, the SSL port or Admin port should be used instead. Location changed to serverRuntime tree. This is a read-only tree with DomainMBean as the root. For more help, use help(domainConfig) Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root. For more help, use help(domainRuntime) Store_MS1 RxP_01.00.16.00_PT Security_01.00.16.00_PT PreEditEngine_01.00.16.00_PT RxPConfig_01.00.16.00_PT Store_MS2 Security_01.00.16.00_PT PreEditEngine_01.00.16.00_PT RxPConfig_01.00.16.00_PT Store_MS3 PreEditEngine_01.00.16.00_PT RxP_01.00.16.00_PT Store_MS4 PreEditEngine_01.00.16.00_PT Sore_MS5 PreEditEngine_01.00.16.00_PT Store_MS6 RxP_01.00.16.00_PT Store_MS7 PreEditEngine_01.00.16.00_PT RxP_01.00.16.00_PT RxPConfig_01.00.16.00_PT Security_01.00.16.00_PT Store_MS8 PreEditEngine_RxC_01.00.16.00_PT Thanks in advance. |
|
||||
|
Not giving me the right output
I run this, but got output as:
Store_MS1: 1 Deployments Store_MS2: 1 Deployments Store_MS3: 1 Deployments Store_MS4: 1 Deployments Store_MS6: 1 Deployments Store_MS7: 1 Deployments Store_MS8: 1 Deployments .. But it supposed to be 4, 3 etc... |
|
||||
|
Try this.
Save the below code in chris2.awk { if (substr($1,1,5)=="Store") { if (NAME!="") { printf("%15s:%15s Deployments\n", NAME, COUNT) } COUNT=0 NAME=$1 } else { COUNT=COUNT+1 } } and if your input file is chris2.txt then run the below command. awk -f chris2.awk chris2.txt Thanks, Chris. |
|
||||
|
You may try this
Code:
#!/usr/bin/ksh
i=0;
j=0;
while read Record
do
if [ ${Record:0:8} == "Store_MS" ]
then
if [ $i != 0 ]
then
printf "number of deployments= %d\n" $j
j=0;
fi
i=1;
printf "%s " $Record;
elif [ $i == 1 ]
then
j=`expr $j + 1`
fi
done < input_file
printf "number of deployments= %d\n" $j
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|