linux shell output to html

后端 未结 5 1815
时光说笑
时光说笑 2020-12-08 05:45

is there any way to convert bash output to html ? for example if I had some colorized output in bash ( something like htop ), how can I convert it to html tags ... ( somethi

5条回答
  •  北海茫月
    2020-12-08 05:56

    1.) check that ansifilter and script programs are installed

    2.) script -c 'ansible-playbook -i /tmp/or/some /tmp/other/command.yml' -O /tmp/myTypescriptOutput.file

    (script writes the output of a command to a file in typescript notation)

    3.) convert to html, e.g. to view with your browser:

    ansifilter -i /tmp/myTypescriptOutput.file -H -o output.html

    convert to rtf, e.g. to view with libreoffice or word

    ansifilter -i /tmp/myTypescriptOutput.file -R -o output.rtf

    see man ansifilter for other options (latex, tex, svg, pangot, txt, ...)


    (additional, if highlight is installed:

    highlight /tmp/myTypescriptOutput.file --force

    ... this will print the saved-shell output in color, like if it was executed at first time)

提交回复
热议问题