【sed】也可以用来替换;
【sed 's#string1#string2#g' file】输出替换,将file中string1替换成string2(用string2替换string1)
【sed -i 's#string1#string2#g' file】真实替换
- s代表查找替换
- g(global全局)与s联合使用,表示对当前行的全局匹配替换
- -i 修改文件内容;
[root@wind data]# cat 3.txt wind wind [root@wind data]# sed 's#wind#rain#g' 3.txt rain rain [root@wind data]# cat 3.txt wind wind [root@wind data]# sed -i 's#wind#rain#g' 3.txt [root@wind data]# cat 3.txt rain rain
【>】输出重定向,还有一个清空文件的功能;
[root@wind data]# cat test.txt test liyao sidihang diwuhang rain [root@wind data]# >test.txt [root@wind data]# cat test.txt [root@wind data]#
【>>】追加重定向
【<】输入重定向
【<<】追加输入重定向
【|】管道,
【\】转义
【./或者.】当前目录
【~】家目录 root目录
【../或者..】当前目录的上级目录
【/】根目录,路径分隔符
【;】命令分隔符
【{ }】字母或者数字的序列(seq一般是数字的序列)
[root@wind data]# echo {a..z} a b c d e f g h i j k l m n o p q r s t u v w x y z
[root@wind data]# mkdir student{01..10} [root@wind data]# ls 1.txt b oldboy student04 student08 2.txt c student01 student05 student09 3.txt d student02 student06 student10 a e student03 student07 test.txt [root@wind data]# rmdir student{01..10} [root@wind data]# ls 1.txt 2.txt 3.txt a b c d e oldboy test.txt [root@wind data]#
【!】
- 【!】+字母,是调出最近一次以此字母开头的命令并且执行;
- 【!!】表示使用最近一次操作的命令并执行;
- 【!】+数字,调出历史的第几次命令并执行。
[root@wind data]# !l ls 1.txt 2.txt 3.txt a b c d e oldboy test.txt
【-】回到用户上一次所在的目录,-由OLDPWD变量控制;
[root@wind /]# cd /data [root@wind data]# cd - / [root@wind /]#
[root@wind data]# env|grep -i win HOSTNAME=wind
按理说会有这个变量,明天看看;
【history】打印用户操作的历史纪录
几个重要的快捷键:
【tab】建议按三次
【Ctrl+A】命令的结尾跳到开头
【Ctrl+E】命令的开头跳到结尾
【Ctrl+U】把光标以前的剪切(区分删除)
【Ctrl+K】把光标以后的删除
【Ctrl+C】终止
【Ctrl+Shift+C】复制
【Ctrl+Shift+V】粘贴
【Ctrl+L】清屏 clear
【Ctrl+D】退出会话,再回车就连接了,相当于exit