|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | 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. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Number of columns in xml file
How to find the number of columns in xml file. i tried following command. Code:
#!bin/ksh cat $1 | grep -c "</mdm:attribute>" exit 0 but i am not getting accurate result which is not matching with the manual count. data format : Code:
<mdm:attribute> value </mdm:attribute> Last edited by Franklin52; 01-08-2013 at 07:36 AM.. Reason: Please use code tags for data and code samples |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Hope this will help you .. Code:
perl -nle 'print $1 if /<\/(.+?)\>/g' file.xml | wc -l |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
It's not perl script it is UNIX ibm aix.
|
|
#4
|
||||
|
||||
|
Did you try to execute the above command?
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
xml doesn't have "columns" per se so I'm not really sure what you want. Could you show a more complete input file and what you're expecting to get from it?
|
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
try also: Code:
awk '{c+=gsub("</mdm:attribute>","&")} END {print c}' file.xml |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
The grep counts lines with matches, not matches. Preprocess the file so every > becomes a line feed and grep for "</mdm:attribute$".
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| concatenate 'n' number of columns in a file | mlpathir | Shell Programming and Scripting | 3 | 10-06-2010 07:24 PM |
| Find number of columns in a file | rahul26 | UNIX for Dummies Questions & Answers | 13 | 05-08-2009 05:11 AM |
| Counting number of columns in a delimited file | net | Shell Programming and Scripting | 4 | 03-05-2009 03:56 AM |
| extract a number within an xml file | tret | Shell Programming and Scripting | 10 | 10-07-2008 07:10 PM |
| Cutting number from range in xml file | nir_s | Shell Programming and Scripting | 4 | 07-25-2005 02:38 AM |
|
|