Sponsored Content
Top Forums Shell Programming and Scripting XML- Sed || Awk Bash script... Help! Post 302550485 by juampal on Friday 26th of August 2011 01:21:30 AM
Old 08-26-2011
Question XML- Sed || Awk Bash script... Help!

Hi ! I'm working into my first bash script to make some xml modification and it's going to make me crazy lol .. so I decide to try into this forum to take some ideas from people that really know about this!

This is my situation I've and xml file with a lots of positional values with another tags too but this are the importants tags
Code:
<x>28.981743194648736</x>
<y>72.4853691731618</y>
<z>0.0</z>
<x>53.46605522341658</x>
<y>54.678596788603365</y>
<z>0.0</z>

and this continue with differents values in the same way
I need to change all the values of x tags by new ones, particulary with random numbers.. the problem that I've is that I have succes to change that values but..... ! , sed change me the value of all the <x> </x> tags with the same value and I need that all that values were differents.. here my code
Code:
#!/bin/bash
NUM=0

while [ $NUM -le 20 ]; do
NUM1=$(echo "scale=3;((${RANDOM})/1000)" |bc)
echo "$NUM1"
sed 's/<x>[-[:alnum:]./]\{1,\}<\/x>/<x>'$NUM1'<\/x>/' myfile.xml > newfile.xml

echo "\$NUM: $NUM"
let NUM=$NUM+1
done

THANKS FOR YOUR TIME ANY IDEA WOULD BE WELCOME !!!

Last edited by Franklin52; 08-28-2011 at 08:56 AM.. Reason: Please use code tags for data and code samples, thank you
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

parsing xml with awk/sed

Hi people!, I need extract from the file (test-file.txt) the values between <context> and </context> tag's , the total are 7 lines,but i can only get 5 or 2 lines!!:confused: Please look my code: #awk '/context/{flag=1} /\/context/{flag=0} !/context/{ if (flag==1) p rint $0; }'... (3 Replies)
Discussion started by: ricgamch
3 Replies

2. Shell Programming and Scripting

sed or awk to extract data from Xml file

Hi, I want to get data from Xml file by using sed or awk command. I want to get the following result : mon titre 1;Createur1;Dossier1 mon titre 1;Createur1;Dossier1 and save it in cvs file (fichier.cvs). FROM this Xml file (test.xml): <playlist version="1"> <trackList> <track>... (1 Reply)
Discussion started by: yeclota
1 Replies

3. Shell Programming and Scripting

Need to Parse XML from bash script

I am completely new to bash scripting and now need to write a bash script that would parse a XML file and take out values from specific tags. I tried using xsltproc, xml_grep commands. But the issue is that the XML i am trying to parse is not UTF 8. so those commands are unable to parse my XML's... (4 Replies)
Discussion started by: shivashankar.g
4 Replies

4. Shell Programming and Scripting

Using SED/AWK to extract xml at end of file

Hello everyone, Firstly i do not require alot of help.. i am right at the end of finishing my scipt but cannot find a solution to the last part. What i need to do is, prompt the user for a file to work with, which i have done. promt the user for an output file - which is done. #!/bin/bash... (14 Replies)
Discussion started by: hugh86
14 Replies

5. Shell Programming and Scripting

Need help in using sed/awk for line insertion in xml

Hello, I have two text files (txt1 and txt2). txt1 contains many lines with a single number in each line. txt2 (xml format) contains information about the numbers given in txt1. I need to insert one line in txt2 within the scope of each number taken from txt1. Sample problem: txt1: 12 23... (1 Reply)
Discussion started by: shekhar2010us
1 Replies

6. UNIX for Dummies Questions & Answers

xml to csv using sed and awk command

Hi Guys, Can you help me in creating shell script using sed,awk etc commands to generate csv file using xml file. (5 Replies)
Discussion started by: sbk
5 Replies

7. Shell Programming and Scripting

'Couldn't read file' error in bash script with expect, sed and awk!

Ok, so I have a bash script with an embedded expect statement. Inside of the expect statement, i'm trying to pull all of the non-comment lines from the /etc/oratab file one at a time. Here's my command: cat /etc/oratab |sed /^s*#/d\ | awk 'NR==1'|awk -F: '{print \"$1\"}'|. oraenv Now,... (0 Replies)
Discussion started by: alexdglover
0 Replies

8. Shell Programming and Scripting

Rsync script to rewrite suffix - BASH, awk, sed, perl?

trying to write up a script to put the suffix back. heres what I have but can't get it to do anything :( would like it to be name.date.suffix rsync -zrlpoDtub --suffix=".`date +%Y%m%d%k%M%S`.~" --bwlimit=1024 /mymounts/test1/ /mymounts/test2/ while IFS=. read -r -u 9 -d '' name... (1 Reply)
Discussion started by: jmituzas
1 Replies

9. Shell Programming and Scripting

Modify xml using sed or awk

Hi All, I want to modify(changing the status from "on" to "off" status of Stage-element value from the below xml file using sed or awk: File Name: global.xml <?xml version="1.0" encoding="UTF-8"?> <config> <widget> <name>HTTP-POOL</name> <attributes> ... (5 Replies)
Discussion started by: wamqemail2
5 Replies

10. Shell Programming and Scripting

Text manipulation with sed/awk in a bash script

Guys, I have a variable in a script that I want to transform to into something else Im hoping you guys can help. It doesn't have to use sed/awk but I figured these would be the simplest. DATE=20160120 I'd like to transform $DATE into "01-20-16" and move it into a new variable called... (8 Replies)
Discussion started by: dendenyc
8 Replies
GRUB-MKFONT(3)						     Library Functions Manual						    GRUB-MKFONT(3)

NAME
grub-mkfont -- Convert common font file formats into the PF2 format. SYNOPSIS
grub-mkfont [--ascii-bitmaps] [-a | --force-autohint] [-b | --bold] [-c | --asce=NUM] [-d | --desc=NUM] [-i | --index=NUM] [-n | --name=NAME] [--no-bitmap] [--no-hinting] <-o | --output=FILE> [-r | --range=FROM-TO[,FROM-TO]] [-s | --size=SIZE] [-v | --verbose] [--width-spec] FONT_FILES DESCRIPTION
grub-mkfont converts font files from common formats into the PF2 format used by GRUB. OPTIONS
--ascii-bitmaps Save only bitmaps for ASCII characters. --force-autohint Force generation of automatic hinting. --bold Convert font to bold. --asce=NUM Set font ascent to NUM. --desc=NUM Set font descent to NUM. --index=NUM Select face index NUM. --name=NAME Set font family to NAME. --no-bitmap Ignore bitmap strikes when loading. --no-hinting Disable hinting. --output=FILE Save ouptut to FILE. This argument is required. --range=FROM-TO,FROM-TO Set the font ranges to each pair of FROM,TO. --size=SIZE Set font size to SIZE. --verbose Print verbose messages. --width-spec Create a width summary file. FONT_FILES The input files to be converted. SEE ALSO
info grub Wed Feb 26 2014 GRUB-MKFONT(3)
All times are GMT -4. The time now is 06:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy