cut ,history命令使用

cut

切割命令

【选项参数】 

-d

指定分隔符

-f数字

取第几列

-c

按字符取

【实践操作】

[root@BingwuA atsshell]# w|sed -n 1p

 00:22:46 up 1 day,  6:35, 3 users,  load average: 0.00, 0.01, 0.05

[root@BingwuA atsshell]# w|sed -n 1p|cut -d ',' -f4-

  load average: 0.00, 0.01, 0.05

[root@BingwuA atsshell]#

[root@BingwuA atsshell]# w|sed -n 1p|cut -d ',' -f4,5,6,7

 load average: 0.00, 0.01, 0.05

history

查看终端用过的历史命令

【选项参数】 

-c

删除用过命令

-w

把缓存中的命令写入历史命令保存文件~/.bash_history

涉及到控制变量

TMOUNT=10 连接超时时间

HISTSIZE=5 命令行历史记录变量

[root@BingwuA ~]# echo $HISTSIZE

1000

HISTFILESZIZE 历史记录文件命令数量变量(~/.bash_history;[root@BingwuA ~]# cat ~/.bash_history

[root@BingwuA ~]# echo $HISTFILESIZE

1000

[root@BingwuA ~]#

设置export HISTTIMEFORMAT='%F %T';临时显示执行时间

  • 历史命令默认保存文件修改HISTFILE=/path/FILENAME
  • 历史命令剔除连续重复的条目HISTCONTROL=ignoredups
  • 历史命令忽略指定命令HISTIGNORE=”pwd:ls:cd:”

猜你喜欢

转载自blog.csdn.net/LINU_BW/article/details/84895143