Xmllint pretty print, batch files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Xmllint pretty print, batch files
# 1  
Old 12-10-2012
Xmllint pretty print, batch files

I have about 20 xml files I want to use xmllint to pretty print:

xmllint --format file01.xml > pretty_file01.xml
xmllint --format file02.xml > pretty_file02.xml
etc

Is there a way I can just use "xmllint --format" on all the current xml files so I don't have to run this command 20 times?? Smilie
# 2  
Old 12-10-2012
How about a for loop with seq:
Code:
for SEQ in $( seq -f "%02g" 1 20 )
do
   xmllint --format file${SEQ}.xml > pretty_file${SEQ}.xml
done

# 3  
Old 12-10-2012
bash:
Code:
for i in {01..20}
do
 xmllint --format file$i.xml > pretty_file$i.xml
done

# 4  
Old 12-10-2012
Thanks bipinajith, I tried what you provided and the script doesn't seem to end. I keep getting > for the next prompt.

---------- Post updated at 09:50 AM ---------- Previous update was at 09:48 AM ----------

to elixir:

what if my filenames aren't file$i.xml?? but apple.xml, banana.xml, grapes.xml??
# 5  
Old 12-10-2012
Quote:
Originally Posted by pxalpine
to elixir:

what if my filenames aren't file$i.xml?? but apple.xml, banana.xml, grapes.xml??
Sigh...why don't you post your exact requirement instead of refining it at every solution provided to you?

May be you need this:
Code:
for i in *.xml
do
 xmllint --format "$i" > pretty_"$i"
done

# 6  
Old 12-10-2012
Sorry! I tried
Code:
for i in *; do xmllint --format $i > pretty_$i; done

and it works, kinda. thanks!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with xmllint

Have like 50 xml files in a folder. They all have a Node named <Number>.How to display the values of <Number> with the count and filename in the folder. I am using Mac . (7 Replies)
Discussion started by: Anethar
7 Replies

2. Shell Programming and Scripting

Accessing files in batch

hai, I have a list of files having extension .sy in a folder. I want to find such files and print the first two columns of the files to new extension .tmp (1 Reply)
Discussion started by: sreejithalokkan
1 Replies

3. Shell Programming and Scripting

Need to exclude .NFSxxx files in clear old files batch script

I am new to Shell Scripting and need some help. The following batch job has been failing for me due to the .nfsxxx files in use. I need to know how to modify the following script to exclude the .nfsxxx files so this batch job will not fail on me. I have done lots of googling and keep coming back... (2 Replies)
Discussion started by: kimberlyg2007
2 Replies

4. Shell Programming and Scripting

Executing a batch of files within a shell script with option to refire the individual files in batch

Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below. I am on a solaris server btw. Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose. ... (2 Replies)
Discussion started by: goddevil
2 Replies

5. UNIX for Dummies Questions & Answers

Batch Renaming of Files

Hello all, thanks for your time (and this forum, what an awesome resource for newbs like myself!) Anyways, I've been given the task of importing content from a directory of about...7000 HTML files. They are all named appropriately and broken down by name depending on what book they belong too.... (8 Replies)
Discussion started by: gratefulhokie
8 Replies

6. Shell Programming and Scripting

xmllint output to a file

Hello All, I have an XML file which has some errors in its tag definition according to an xsd. When i validate this xml file against an xsd, i wish to only take the errors in a file and not the complete xml. for eg. Raman.xml has some errors induced in it. RamanValidator.xsd holds the schema... (5 Replies)
Discussion started by: damansingh
5 Replies

7. UNIX for Advanced & Expert Users

iconv and xmllint

Here is my question, volume of records processed : 5M ( approx ) Its basically very simple operation that am trying to do and I had achieved the output that am interested. What am looking for really is to improve the performance, an optimized way to do that. with respect to iconv, am... (3 Replies)
Discussion started by: matrixmadhan
3 Replies

8. Programming

I am pretty new to this

Ok, so I need to make a program using PICO. Here is the assignment, if anyone knows how to do this please show me. Thanks. Acme Paints, a well-respected local paint store, is having their big End-Of-Winter Paint Sale. They have way too much red, green, yellow, and blue paint on hand in their... (1 Reply)
Discussion started by: thescene
1 Replies

9. UNIX for Dummies Questions & Answers

Deleting a batch of print jobs

Hi Guys I have over 2000+ print jobs in one queue which I would like to delete. Is there away in AIX 4.3 that I can delete the whole print jobs at ocne. Instead of one at a time. Thanks (1 Reply)
Discussion started by: orvelb
1 Replies

10. UNIX for Dummies Questions & Answers

how to batch & print hpgl files to xerox device

have electronic files from customer with .gl extension; are hpgl files originating from Unix. Need utility to open, batch and print in directory order on xerox docutech. Any ideas? Help greatly appreciated. (5 Replies)
Discussion started by: theresa
5 Replies
Login or Register to Ask a Question