zoukankan      html  css  js  c++  java
  • shell 基础 history table键 通配符 输入输出重定向

    cent os 的 shell   -->bash  bourne agin shell  (以人命名的shell),还有 zsh  ksh 

    在shell  用向上或向下的方向键,可以看之前输入过的命令:

    输入 : history 可以查看 之前输入 过的历史命令,具体如下:

    具体的命令:

    [root@one_year ~]# history 可以查看之前的历史命令^C
    [root@one_year ~]# history | tail -3
    228 LANG=zh_CN.UTF-8
    229 echo $LANG
    230 history | tail -3
    [root@one_year ~]# history -c 可以清空内存里的缓存,但不能清楚历史记 录里的 ^C
    [root@one_year ~]# history -c
    [root@one_year ~]# tail -3 .bash_history
    yum list
    yum list | grep -E "zsh|ksh"
    history
    [root@one_year ~]# ls
    [root@one_year ~]# ls .
    [root@one_year ~]# l.
    . .bash_logout .cache .pki .tcshrc
    .. .bash_profile .cshrc .pydistutils.cfg .viminfo
    .bash_history .bashrc .pip .ssh
    [root@one_year ~]# .bash_history 存的就是历史命令记录 ^C
    [root@one_year ~]# cat /etc/profile | grep "HIS"
    HISTSIZE=1000
    if [ "$HISTCONTROL" = "ignorespace" ] ; then
    export HISTCONTROL=ignoreboth
    export HISTCONTROL=ignoredups
    export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
    [root@one_year ~]# sed -i "s/1000/2000/" /etc/profile
    [root@one_year ~]# echo $HISTSIZE
    1000
    [root@one_year ~]# source /etc/profile
    [root@one_year ~]# echo $HISTSIZE
    2000
    [root@one_year ~]# HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S "
    [root@one_year ~]# history | tail -3
    10 2018/04/21 00:07:06 echo $HISTSIZE
    11 2018/04/21 00:10:42 HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S "
    12 2018/04/21 00:10:58 history | tail -3
    [root@one_year ~]# echo "HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S "" >> /etc/profile
    [root@one_year ~]# source /etc/profile
    [root@one_year ~]# chattr +a ~/.bash_history 加这个权限,那么,这里 面的历史记录都会被追加进入,而且,永远不会被删除。 ^C
    [root@one_year ~]# history | tail -5
    12 2018/04/21 00:10:58 history | tail -3
    13 2018/04/21 00:15:29 echo "HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S "" >> /etc/profile
    14 2018/04/21 00:16:03 source /etc/profile
    15 2018/04/21 00:20:21 history | tail 5
    16 2018/04/21 00:20:38 history | tail -5
    [root@one_year ~]# !14 执行历史记录中的那一条 ^C
    [root@one_year ~]# !12
    history | tail -3
    15 2018/04/21 00:20:21 history | tail 5
    16 2018/04/21 00:20:38 history | tail -5
    17 2018/04/21 00:21:31 history | tail -3

     关于命令补全:

    最常用的是table   键:

    [root@one_year ~]# yum install bash-completion  -y 安装补全参数的插件 ,装完成之后需要重启计算机才能生效

    alias 命令:

    通配符:* 、?、[ ]、{ }

    输入输出重定向:

  • 相关阅读:
    突破ASLR之理论篇
    安装cocoaPods
    iOS 文字渐变
    iOS_科大讯飞快速实现语音搜索功能Demo
    Button宽度自定义
    全局手势按钮(随意拖动,点击事件)
    文字广告轮播这个就够用了
    一些有趣的三方开源库
    SVN的简单使用和积累
    如何在手机上面安装iPA应用包
  • 原文地址:https://www.cnblogs.com/nfyx/p/8895145.html
Copyright © 2011-2022 走看看