how to increase the integer in a xml file

Hi
Need a Script. Problem is I want to increase the integer in a xml file

example

the xml file is

<name>
<school> Public School
<label>01
</label>
</school>
</name

so when every time when it gets <label> it will increase the value 01 to 02 and store the total increased valued file to a new xml file

Hi.

My first thought is...

awk -F">" '/^<label/ { print $1 ">" ++$2 }' your_file.xml > your_new.xml

(edited to add ] to closing code section!)

Scott Thanks..

But is there any other way like using cut or cat ?

May I ask why, specifically?

Because I dont know AWK

You don't have to... I just showed you :slight_smile:

If you want to learn it, the internet is awash with stuff on AWK, and you can look at the man page.

ok Thanks !!!!!!!!!

Hello,

Per our forum rules, all threads must have a descriptive subject text. For example, do not post questions with subjects like "Help Me!", "Urgent!!" or "Doubt". Post subjects like "Execution Problems with Cron" or "Help with Backup Shell Script".

The reason for this is that nearly 95% of all visitors to this site come here because they are referred by a search engine. In order for future searches on your post (with answers) to work well, the subject field must be something useful and related to the problem!

In addition, current forum users who are kind enough to answer questions should be able to understand the essence of your query at first glance.

So, as a benefit and courtesy to current and future knowledge seekers, please be careful with your subject text.

Thank you.

The UNIX and Linux Forums