shell常见操作整理(更新)

查看文件第20到30行的内容

法一:[root@oldboy ~]# seq 100 > ett.txt
[root@oldboy ~]# head -30 ett.txt | tail -11
法二:sed stream editor  流编辑器  实现对文件的增删改查
[root@oldboy ~]# sed -n '20,30p' ett.txt  -n 取消默认输出          // 效率最高
法三: awk   过滤、输出内容、一门语言   NR : 行号
[root@oldboy ~]# awk 'NR>19&&NR<31' ett.txt
[root@test88 ~]# awk 'NR==20,NR==30' ett.txt 法四:[root@oldboy ~]# awk '{if(NR<31&&NR>19) printf $0"\n"}' ett.txt 法五:[root@oldboy ~]# grep 20 -A 10 ett.txt // 匹配20所在行,以及之后10行 法六:[root@oldboy ~]# grep 30 -B 10 ett.txt // 匹配30所在行,以及之前10行

 隐藏系统版本信息

[root@oldboy ~]# cat /etc/issue
CentOS release 6.6 (Final)
Kernel \r on an \m
[root@oldboy ~]# > /etc/issue
[root@oldboy ~]# > /etc/issue.net        

 查看磁盘UUID

[root@test88 ~]# blkid
/dev/sda1: UUID="3188b530-e133-4377-8f5a-df8c3128977a" TYPE="ext4" 
/dev/sda2: UUID="b75c5e58-2f6d-4d77-8da1-0334575b03f7" TYPE="swap" 
/dev/sda3: UUID="4b7af0df-b28a-4c69-b49d-e6277c299cd1" TYPE="ext4" 

 查看文件系统inode总量以及剩余量

[root@test88 ~]# df -i
Filesystem      Inodes IUsed   IFree IUse% Mounted on
/dev/sda3      1250928 82454 1168474    7% /
tmpfs           125543     1  125542    1% /dev/shm
/dev/sda1        51200    38   51162    1% /boot

 查看磁盘的使用量

[root@test88 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        19G  2.0G   16G  12% /
tmpfs           491M     0  491M   0% /dev/shm
/dev/sda1       190M   27M  153M  16% /boot

 

posted @ 2017-09-20 23:46  Peterer~王勇  阅读(277)  评论(0编辑  收藏  举报