美文网首页
shell-0.基础

shell-0.基础

作者: 青丝如梦 | 来源:发表于2020-03-07 14:14 被阅读0次

    &
    使用$!获取执行上一个后台程序的PID时,上一个后台指令必须要以&结尾,否则无法获取到PID

    &&
    前面的命令执行成功,才执行后续

    ;(分号)
    表示两个命令写在一行时,互不影响,前面的命令报错不会影响后面命令执行

    [root@VM_16_6_centos ~]# 
    [root@VM_16_6_centos ~]# ls /optt && ls
    ls: cannot access /optt: No such file or directory
    [root@VM_16_6_centos ~]# ls /optt ; ls
    ls: cannot access /optt: No such file or directory
    example.sh  read.sh  redis-stable.tar.gz  z.sh
    [root@VM_16_6_centos ~]# 
    

    !$
    执行上一个命令时, 不必再输入参数

    [root@VM_16_6_centos ~]# ps aux | grep top
    root     31734  0.0  0.1 159780  2140 pts/1    S+   13:34   0:00 top
    root     31936  0.0  0.0 112708   980 pts/0    R+   13:35   0:00 grep --color=auto top
    [root@VM_16_6_centos ~]# ps aux | grep !$
    ps aux | grep top
    root     31734  0.0  0.1 159780  2140 pts/1    S+   13:34   0:00 top
    root     31954  0.0  0.0 112708   980 pts/0    R+   13:35   0:00 grep --color=auto top
    [root@VM_16_6_centos ~]# 
    

    相关文章

      网友评论

          本文标题:shell-0.基础

          本文链接:https://www.haomeiwen.com/subject/yilbrhtx.html