history 命令历史,命令补全,别名

history 命令历史

[root@binbinlinux ~]# echo $HISTSIZE   查看history  命令

1500

[root@binbinlinux ~]# !!            上一次的命令结果

echo $HISTSIZE

1500

[root@binbinlinux ~]# ls 12.txt

12.txt

[root@binbinlinux ~]# cat !$         !$¥执行上一次的命令结果

cat 12.txt

11111

11111

history  还可以指定第几条命令   比如!987   他就会从 命令历史里从新执行这条命令

!c     就是从命令历史查找最近的以C 开头的命令  然后去执行

tab 键可以补全   例如 his按tab键就可补全

alias   别名

[root@binbinlinux ~]# alias ccc='cat 1.txt'    自定义别名

[root@binbinlinux ~]# alias        查看别名

alias ccc='cat 1.txt'

alias cp='cp -i'

alias l.='ls -d .* --color=auto'

alias ll='ls -l --color=auto'

alias ls='ls --color=auto'

alias mv='mv -i'

[root@binbinlinux ~]# unalias ccc     取消别名 unalias    

[root@binbinlinux ~]# ccc                  在次输入报错了

-bash: ccc: command not found

[root@binbinlinux ~]# ls *.txt             *表示通配符  会把.txt的文件全部列出来

0.txt  123.txt  12.txt  1.txt  6.txt  p.txt  test.txt

[root@binbinlinux ~]# ls ?.txt              还可以用?号 匹配 一个字符     多位数匹配不到 1111

0.txt  1.txt  6.txt  p.txt

[root@binbinlinux ~]# cat /etc/passwd |wc -l   管道符把这个命令丢给另一个命令  查看它的行

29

[root@binbinlinux ~]# cat /etc/passwd > 2.txt    重定向  > 会把原来的内容消失

[root@binbinlinux ~]# echo "dajslaksdjalksj" > 2.txt     

[root@binbinlinux ~]# cat 2.txt   查看 

dajslaksdjalksj

[root@binbinlinux ~]# echo "dajslaksdjalksj" >>2.txt  追加重定向  

[root@binbinlinux ~]# echo "dajslaksdjalksj" >>2.txt

[root@binbinlinux ~]# cat 2.txt

dajslaksdjalksj

dajslaksdjalksj

[root@binbinlinux ~]# wc -l < 2.txt   反向重定向  把命令丢给 2.txt

3

[root@binbinlinux ~]# ls 1111 > 2.txt   正确重定向  只重定向正确的信息

ls: 无法访问1111: 没有那个文件或目录

[root@binbinlinux ~]# ls 1111 2> 2.txt  2>也是正确重定向  

[root@binbinlinux ~]# cat 2.txt

ls: 无法访问1111: 没有那个文件或目录

[root@binbinlinux ~]# ls 1111 2>> 2.txt   追加错误重定向  

[root@binbinlinux ~]# cat 2.txt

ls: 无法访问1111: 没有那个文件或目录

ls: 无法访问1111: 没有那个文件或目录

[root@binbinlinux ~]# sleep 100    ctrl +z 把一个命令暂停 Stopped 

^Z

[1]+  Stopped                 sleep 100

[root@binbinlinux ~]# jobs   用jobs查看已经暂停的内容

[1]+  Stopped                 sleep 100

[root@binbinlinux ~]# sleep 122    sleep 是睡眠 

^Z

[2]+  Stopped                 sleep 122

[root@binbinlinux ~]# jobs   查看哪些任务 内容

[1]-  Stopped                 sleep 100

[2]+  Stopped                 sleep 122

[root@binbinlinux ~]# fg   掉到前台来 fg

sleep 122

^Z

[2]+  Stopped                 sleep 122

[root@binbinlinux ~]# sleep 1222  

^Z

[3]+  Stopped                 sleep 1222

[root@binbinlinux ~]# jobs 

[1]   Stopped                 sleep 100

[2]-  Stopped                 sleep 122

[3]+  Stopped                 sleep 1222

[root@binbinlinux ~]# fg  带+号的优先级更高一点 可以选择数字 fg2 就是掉第二个

sleep 1222

^Z

[3]+  Stopped                 sleep 1222

[root@binbinlinux ~]# fg 2  掉第二个

sleep 122

^Z

[2]+  Stopped                 sleep 122

[root@binbinlinux ~]# bg  bg 是后台 调到后台  带&的 

[2]+ sleep 122 &

[root@binbinlinux ~]# jobs   

[1]-  Stopped                 sleep 100

[2]   Running                 sleep 122 &

[3]+  Stopped                 sleep 1222

[root@binbinlinux ~]# fg 2

sleep 122

^Z

[2]+  Stopped                 sleep 122

[root@binbinlinux ~]# bg

[2]+ sleep 122 &

[root@binbinlinux ~]# fg 2  

-bash: fg: job has terminated

[2]   Done                    sleep 122


本文转自 amenging 51CTO博客,原文链接:http://blog.51cto.com/11335852/1982210

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值