Skip to content

Instantly share code, notes, and snippets.

@ushkinaz
Last active December 30, 2015 18:39
Show Gist options
  • Save ushkinaz/7869356 to your computer and use it in GitHub Desktop.
Save ushkinaz/7869356 to your computer and use it in GitHub Desktop.
Форматирует и выводит в консоль файл пакетов Агент.ру Требует наличия в системе: * xsltproc * pygmentize
#!/bin/sh
# Форматирует и выводит в консоль файл пакетов Агент.ру
# Требует наличия в системе:
# xsltproc
# pygmentize
XSL_TRANSFORM='<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>'
xsl_file=$(mktemp /tmp/pack.tmp.XXXXXXXXXX.xsl)
xml_file=$(mktemp /tmp/pack.tmp.XXXXXXXXXX.xml)
echo $XSL_TRANSFORM > $xsl_file
# Самый сок
sed -e '/\(Outbound\|Inbound\) Message/,/Headers: /d;$d;s/Payload: //' $1 | xsltproc $xsl_file - > $xml_file
# Через пайпу не работает с некоторыми символами. wtf
pygmentize -l xml -f console $xml_file
rm -f "$xsl_file"
rm -f "$xml_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment