The last few lines of my file /usr/share/glib-2.0/schemas/org.gnome.Vino.gschema.xml
:
<schemalist>
<schema>
<!-- some other tags -->
<key name='notify-on-connect' type='b'>
<summary>Notify on connect</summary>
<description>
If true, show a notification when a user connects to the system.
</description>
<default>true</default>
</key>
<key name='enabled' type='b'>
<summary>Enable remote access to the desktop</summary>
<description>
If true, allows remote access to the desktop via the RFB
protocol. Users on remote machines may then connect to the
desktop using a VNC viewer.
</description>
<default>false</default>
</key>
</schema>
</schemalist>
If I want to grep
this paragraph:
<key name='enabled' type='b'>
<summary>Enable remote access to the desktop</summary>
<description>
If true, allows remote access to the desktop via the RFB
protocol. Users on remote machines may then connect to the
desktop using a VNC viewer.
</description>
<default>false</default>
</key>
How should I use the grep
command to achieve this?
grep
? If<key name='enabled' type='b'>
only occur once, it would be easier to useawk
(or perhapssed
or evenbash
). Or - of course something likepython
,perl
,php
, ... as in something that supports xml.grep
for such tasks.grep
is useful for parsing line-oriented data such as/etc/passwd
, but it's not useful for parsing structured data like XML, JSON or YAML. If you want to parse XML, use tools designed for parsing XML (such as what others have posted,xq
,xmlstarlet
,xmllint
, XSL,LibXML
).