如何记录终端输出?
试试使用script命令行工具来为你的终端输出创建输出记录。
script caimz.terminal.session #
caimz.terminal.session 就是随便起一个名字,我利于认识我起了能认识的名字
[root@PXE ~]# script caimz.terminal.session #开启
Script started, file is caimz.terminal.session
[root@PXE ~]# ls
1 1.txt anaconda-ks.cfg caimz.terminal.session install.log install.log.syslog ks.cfg nohup.out
[root@PXE ~]# cd /usr/local/src/
[root@PXE src]# ll
total 752480
drwxr-xr-x 14 root root 4096 Dec 15 07:36 cmake-2.8.7
-rw-r--r-- 1 root root 5667409 Dec 15 06:51 cmake-2.8.7.tar.gz
-rw-r--r-- 1 root root 4704761 Oct 9 22:39 Discuz_7.2_FULL_SC_UTF8.zip
drwxr-xr-x 12 1000 1000 4096 Dec 15 18:27 httpd-2.2.31
-rw-r--r-- 1 root root 7583841 Jul 16 10:12 httpd-2.2.31.tar.gz
-rw-r--r-- 1 root root 129074609 Nov 4 2013 mysql-5.1.73-linux-i686-glibc23.tar.gz
-rw-r--r-- 1 root root 584116380 Nov 29 11:50 mysql-5.7.10-linux-glibc2.5-i686.tar.gz
drwxr-xr-x 18 1000 1000 4096 Dec 15 18:54 php-5.6.13
-rw-r--r-- 1 root root 14077633 Sep 3 08:40 php-5.6.13.tar.bz2
-rw-r--r-- 1 root root 10039255 Dec 16 06:23 phpMyAdmin-4.4.13.1-all-languages.zip
-rw-r--r-- 1 root root 7763122 Nov 23 04:56 phpMyAdmin-4.5.2-all-languages.tar.bz2
drwxr-xr-x 2 root root 4096 Dec 15 07:51 tarbag
-rw-r--r-- 1 root root 7475647 Dec 16 01:42 wordpress-4.4-zh_CN.tar.gz
[root@PXE src]# cd /data/
[root@PXE data]# ls
blog mysql phpmyadmin www
[root@PXE data]# cd blog/
[root@PXE blog]# ls
index.php wordpress-4.4-zh_CN.tar.gz wp-comments-post.php wp-cron.php wp-login.php wp-trackback.php
license.txt wp-activate.php wp-config.php wp-includes wp-mail.php xmlrpc.php
readme.html wp-admin wp-config-sample.php wp-links-opml.php wp-settings.php
wordpress wp-blog-header.php wp-content wp-load.php wp-signup.php
[root@PXE blog]# cd ../../
[root@PXE /]# s
bash: s: command not found
[root@PXE /]# ls
bin centosinstall dev home lost+found mnt proc root selinux sys tmp var
boot data etc lib media opt pxeftp sbin srv tftpboot usr
要退出(结束script会话),输入 exit 或者 logout 或者按下 control-D。
exit
[root@PXE /]# exit 退出
exit
Script done, file is caimz.terminal.session
[root@PXE ~]# ll
total 80
-rw-r--r-- 1 root root 1807 Dec 13 01:56 1
-rw-r--r-- 1 root root 89 Dec 16 07:31 1.txt
-rw-------. 1 root root 2676 Dec 10 03:11 anaconda-ks.cfg
-rw-r--r-- 1 root root 2868 Dec 21 18:03 caimz.terminal.session #这个就是刚才我记录那个文档
-rw-r--r--. 1 root root 39935 Dec 10 03:11 install.log
-rw-r--r--. 1 root root 9154 Dec 10 03:10 install.log.syslog
-rw-r--r-- 1 root root 1032 Dec 12 02:23 ks.cfg
-rw------- 1 root root 883 Dec 12 01:49 nohup.out
要浏览输入:
more caimz.terminal.session
less caimz.terminal.session
cat caimz.terminal.session
即可查看之前的操作。