Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xmllint: Formating without adding header

Tags:

bash

xmllint

Is there a way to use $xmllint --format file without the header section?

<?xml version="1.0"?>
<Tag>
  <Sub>A</Sub>
</Tag>

I know you can use --c14n but that does not seem to mix well with --format. As $xmllint --format --c14n file will just produce:

<Tag><Sub>A</Sub></Tag>

Desired Result

<Tag>
  <Sub>A</Sub>
</Tag>
like image 797
Overseer10 Avatar asked Mar 23 '26 06:03

Overseer10


1 Answers

You can use sed to remove the first line. Not saying it's the best but it would get you going:

xmllint --format <file> | sed 1d

You would preferrable try to avoid one million calls to xmllint. And sed or tail.

I'm not sure if xmllint supports inplace edit. But if it does then something like this might be possible:

xargs < list_of_files_to_change.txt xmllint --inplace --format
xargs < list_of_files_to_change.txt sed -i 1d
like image 94
Andreas Louv Avatar answered Mar 25 '26 00:03

Andreas Louv