执行命令:ll /etc | head -5
执行命令:cat /etc/profile | tail -5
执行命令:ll /etc | grep python
执行命令:cat /etc/profile | grep dev
执行命令:cat /etc/passwd | grep how*
执行命令:grep hi d*
执行命令:grep 'hadoop' demo.txt demo1.txt
执行命令:grep '[a-z]\{7\}' demo.txt
/ grep '[a-z]\{6\}' demo.txt
执行命令:find /etc/sysconfig -type 'd'
执行命令:find /etc/sysconfig -name ‘network’
执行命令:find /etc/sysconfig -name 'net*'
(可使用通配符)
执行命令:find /etc/sysconfig -size 15c
(等于15字节)
执行命令:find /etc/sysconfig -size +10k
(大于10240个字节)
find /etc/sysconfig -size -20c
(小于20个字节)
执行命令:find /etc/sysconfig -perm '777'
(权限字符串:rwxrwxrwx)
find /etc/sysconfig -perm '755'
(权限字符串:rwxr-xr-x)
执行命令:sed "s/hello/HELLO/" demo.txt
执行命令:sed "2,3s/hello/HELLO/2" demo.txt
执行命令:sed "2s/hello/HELLO/g" demo.txt
执行命令:sed "s/hello/HELLO/g" demo.txt > demo1.txt
执行命令: sed -i "s/hello/hi/g" demo.txt
执行命令:sed "2 i I love Linux" demo.txt
执行命令:sed "2 a Linux is fun and I love it" demo.txt
执行命令:sed '2d' demo.txt
执行命令: sed '2,3d' demo.txt
执行命令:sed 'd' demo.txt
执行命令:sed '/scala/g' demo.txt
执行命令:tail -n 4 anaconda-ks.cfg
执行命令:tail -c 4 love.txt
tail -f filename 显示文件修改的内容。
说明:监视filename文件的尾部内容(默认10行,相当于增加参数 -n 10),刷新显示在屏幕上。退出,按下CTRL+C。
查看test.txt内容
修改test.txt,在末尾增加10换行内容,然后存盘退出
预备工作:创建ips.txt文件
执行命令:sort ips.txt
,按字典排序法升序排列
执行命令:sort -r ips.txt
,按字典排序法降序排列
执行命令:sort -t '.' -k 4 ips.txt
,升序排列
执行命令:sort -t '.' -k 4 -r ips.txt
,降序排列
执行命令:cut -c 7 ips.txt
执行命令:cut -b 7 ips.txt
执行命令:cut -d '.' -f 4 ips.txt
,提取第4节内容
执行命令:cut -d '.' -f 2 ips.txt
,提取第2节内容
执行命令:history
执行命令:history 10
(写成history -n 10也是一样效果)
执行命令:history | head -10
执行命令:history | grep vim
查看历史第5条命令
执行命令:!5
执行命令:!!
执行命令:!his
执行命令:history -w myhis
执行命令:cat myhis | tail -5
查看第5条历史命令
执行命令:history -d 5
执行命令:history -c
执行命令:history -r myhis
创建脚本文件,执行命令:vim /home/shell.sh
此时,shell.sh对于所有者而言,只有读和写的权限,并不是可执行的脚本
执行命令:/home/shell.sh
执行命令:cd /home
执行命令:./shell.sh
(.表示当前目录)
执行命令:source shell.sh
执行命令:bash shell.sh
执行命令: sh shell.sh
执行命令:vim shell01.sh
执行命令:chmod u+x shell01.sh
,增加可执行权限
执行命令:./shell01.sh
切换到其他用户,看一看是否能够执行该脚本呢?
执行命令:chmod u+x shell02.sh
执行命令:./shell02.sh