Count number of Nodes created and write it to a Log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Count number of Nodes created and write it to a Log file
# 1  
Old 06-29-2009
Count number of Nodes created and write it to a Log file

Dear Experts,

I have to count the number of AddressRecords formed in bbc.xml file using unix script file. For example: for below pasted file, I need to write an output to a log file as "No. of Address Records Created=4".


Snippet of bbc.xml:-

Code:
  <?xml version="1.0" encoding="UTF-8" ?> 
- <ns0:MT_AddressDetails xmlns:ns0="http://CMS/AddressDetails">
+ <AddressRecords>
  <UniqueID>1</UniqueID> 
  <TransType>1</TransType> 
  <Name1>1</Name1> 
  <TelephoneNo1>1</TelephoneNo1> 
  <MobileNoEmail>1</MobileNoEmail> 
  </AddressRecords>
+ <AddressRecords>
  <UniqueID>2</UniqueID> 
  <TransType>2</TransType> 
  <Name1>2</Name1> 
  <TelephoneNo1>2</TelephoneNo1> 
  <MobileNoEmail>2</MobileNoEmail> 
  </AddressRecords>
+ <AddressRecords>
  <UniqueID>3</UniqueID> 
  <TransType>3</TransType> 
  <Name1>3</Name1> 
  <TelephoneNo1>3</TelephoneNo1> 
  <MobileNoEmail>3</MobileNoEmail> 
  </AddressRecords>
+ <AddressRecords>
  <UniqueID>4</UniqueID> 
  <TransType>4</TransType> 
  <Name1>4</Name1> 
  <TelephoneNo1>4</TelephoneNo1> 
  <MobileNoEmail>4</MobileNoEmail> 
  </AddressRecords>
  </ns0:MT_AddressDetails>

Thanks,
Phani Akella.

Last edited by Yogesh Sawant; 06-30-2009 at 03:49 AM.. Reason: added code tags
# 2  
Old 06-30-2009
Code:
awk '/AddressRecords/{e++}END{print "No of records: "e}' file

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count Segmentation fault and write to the file

Hi everyone Need to get version of npm application that have several output like this: root: nmp -version 10 root: nmp -version 10 root: nmp-new -version 3.1 root: nmp-old -version Segmentation fault count them , after that write to the file like this: 10 2 3.1 1 (1 Reply)
Discussion started by: indeed_1
1 Replies

2. Shell Programming and Scripting

Remote nodes - login and find number of processes

Hello all, This is my requirement: 1. I have 6 VMs running Apache (for Oracle EBS) as Linux user oracle. 2. From a central server (VM), I need to login to all the 6 VMs as oracle user (I have already set up ssh equivalence, so it is password less authentication). 3. Find the number of... (4 Replies)
Discussion started by: sunpraveen
4 Replies

3. Shell Programming and Scripting

How to count number of files in directory and write to new file with number of files and their name?

Hi! I just want to count number of files in a directory, and write to new text file, with number of files and their name output should look like this,, assume that below one is a new file created by script Number of files in directory = 25 1. a.txt 2. abc.txt 3. asd.dat... (20 Replies)
Discussion started by: Akshay Hegde
20 Replies

4. UNIX for Dummies Questions & Answers

Count the lines with the same values in a column and write the output to a file

Hey everyone! I have a tab delimited data set which I want to create an output contained the calculation of number of those lines with a certain value in 2nd and 3rd column. my input file is like this: ID1 1 10M AAATTTCCGG ID2 5 4M ACGT ID3 5 8M ACCTTGGA ID4 5 ... (7 Replies)
Discussion started by: @man
7 Replies

5. Shell Programming and Scripting

write specific line number in file

dear all, i need your advice i have sample script like this: testing.sh for i in {1..10} do echo testing $i done but i forgot create "#!/bin/bash" in above "for" so i want output will like this testing.sh #!/bin/bash for i in {1..10} do echo testing $i done (2 Replies)
Discussion started by: zvtral
2 Replies

6. UNIX for Advanced & Expert Users

Count number of unique patterns from a log file

Hello Everyone I need your help in fixing this issue., I have a log file which has data of users logging in to an application. I want to search for a particular pattern in the log ISSessionValidated=N If this key word is found , the above 8 lines will contain the name of the user who's... (12 Replies)
Discussion started by: xtechkid
12 Replies

7. Shell Programming and Scripting

d. Write a shell script to count the number of accounts which belong to particular primary

guys, I am new shelll scripting.. this a question on passt exam paper, I was trying to solve it , I can not. the question is as follow? a. Write a shell script to count the number of accounts which belong to particular primary group in a standard UNIX system which uses local... (1 Reply)
Discussion started by: gurmad
1 Replies

8. Shell Programming and Scripting

scripting - write a script that will count the number of times a particular word

hello everyone, I'm trying to learn some scripts but i cant get my head around two of them. 1. how can i write a script that will count the number of times a particular word is used in file? 2. how can i make a script that will take me to a web page from unix? if anyone could help it... (3 Replies)
Discussion started by: BigTool4u2
3 Replies

9. Shell Programming and Scripting

File number count

hi all i want to count the number of files in a particlar dir i have wrote the codes as below fileCount= ls | wc -l if then echo " " elif then echo " " fi however when i excute the program there are error happens " unary operator expected" i just woundering fileCount=... (4 Replies)
Discussion started by: cryogen
4 Replies
Login or Register to Ask a Question