|||
第12次课正则表达式
[root@guohuiqiang ~]# alias
aliascp='cp -i'
aliasl.='ls -d .* --color=auto'
aliasll='ls -l --color=auto'
aliasls='ls --color=auto'
aliasmv='mv -i'
aliasrm='rm -i'
aliaswhich='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@ghq ~]# a='pwd'
[root@ghq ~]# echo $a
Pwd
声明一个全局变量: export,是当前的shell和其子shell,如果再打开一个终端,则不会生效。要想再另一个终端生效,需要修改配置文件:etc/profile, etc/bashrc,etc/.bashrc etc/.bash_profile
修改umask,修改etc/profile文件。
[root@ghq ~]#ls
~]# aaa.log Downloads mkfs.ext Templates
2014zuihouyiwang.log aaa.txt err.out Music Videos
2015.log all.log guo new_file
2.log anaconda-ks.cfg guo.log Pictures
aaa Desktop install.log Public
aaaa Documents install.log.syslog sss.log
[root@ghq ~]#ls [aaa].txt(为啥中括号不起作用啊?)
ls:cannot access [aaa].txt: No such file or directory
[root@ghq~]#touch A.txt
[root@ghq ~]#ls [a-zA-Z].txt (新创建一个文件有用)
A.txt
[root@ghq ~]#ls [a-z].txt(a-z为啥包括了A??)
中括号只表示其中的任意一个字符
A. txt
连接符:
[root@ghq~]#cm1 && cm2
[root@ghq~]#cm1 || cm2
[root@ghq~]#cm1 ; cm2
命令cut的使用,功能不是很强大
[root@ghq~]#cd /pub
[root@ghqpub]#ls
aa aming aminghard bbb.txt ccc.txt guo lei passwd ps.out
[root@ghq pub]#cut -d ':' -f 1 passwd |head
root
bin
daemon
adm
lp
sync
shutdown
halt
uucp
[root@ghqpub]#cut --version
cut(GNU coreutils) 8.4
Copyright(C) 2010 Free Software Foundation, Inc.
LicenseGPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
Thisis free software: you are free to change and redistribute it.
Thereis NO WARRANTY, to the extent permitted by law.
Writtenby David M. Ihnat, David MacKenzie, and Jim Meyering.
[root@ghq pub]#echo 'abc' |tr 'a' 'b'(tr 替换)
bbc
[root@ghqpub]#echo 'abc' |tr 'a-z' 'A-Z'
ABC
正则表达式(grep egrep sed awk)
[root@ghqpub]#grep 'root' passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
[root@ghqpub]#grep 'root' passwd -n
1:root:x:0:0:root:/root:/bin/bash
11:operator:x:11:0:operator:/root:/sbin/nologin
[root@ghqpub]#grep 'root' passwd -x
[root@ghqpub]#grep 'root' passwd -c
2
[root@ghq pub]#grep --color=auto 'root' passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-9-27 23:31
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社