微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用linux脚本命令

script命令执行并记录日志.

(http://www.computerhope.com/unix/uscript.htm)

(http://linuxers.org/article/script-command-line-tool-recordsave-your-terminal-activity)

我使用script命令来保存命令和那些输出.

每当使用’script’时,我都会输入如下命令.

$script result.log
Script started, file is result.log
$date
$ls -la.
$exit

有时我想在shell脚本中使用这些命令.

所以我跑得像以下.

$script -c test.sh result.log

但是result.log只有输出,它不包含命令本身.
我希望result.log包含命令和输出.

我该怎么做?

谢谢

解决方法:

如果你使用sh -x来运行你的脚本,它将打印命令或添加
将-x设置为您的脚本.

script -c "sh -x ./test.sh" reult.log

样本输出

+ date
Tue Dec 23 09:52:22 CET 2014
+ ls -la

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐