linux - 将 unix 操作系统命令的外部重定向到 html 页面

标签 linux unix command

如何将 unix 操作系统命令重定向并导出到 HTML 页面?

最佳答案

尝试这样的事情(使用命令 ls):

# start the html file
echo "<html lang="en"><head><title>Command Output</title></head><body><table>" > output.html

# get the data needed to a file for processing
ls -lah >> output.html

# escape html entities with PHP (optional but recommended)
cat output.html | php -R 'echo html_entity_decode($argn);' > output2.html

# enclose each line in a html table row
while read line; do echo "<tr><td>$line</tr></td>"; done < output2.html > output3.html

# finish the file with the html closing tags
echo "</table></body></html>" >> output2.html

关于linux - 将 unix 操作系统命令的外部重定向到 html 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30730730/

相关文章:

c - 如何在 U-Boot 中添加用户自定义函数?

c - 在 Linux 上测量增量时间时出现奇怪的结果

c - 可执行文件格式

linux - 仅列出 linux 中的数字目录名称

c - 编写打印人类可读时间的内核系统调用

bash - 在 Unix shell 中反转文件

linux - 通过引用发送文件到远程服务器?

validation - 如何使用 @Validateable 和 @BindUsing 对 Grails 命令对象进行单元测试

linux - 如何在 Linux 中创建自定义 bash 命令

BASH - 类似字符串的命令