1、查看⽂件最后100⾏的命令是( )。
tail -100
2、显⽰/etc/inittab中以#开头,且后⾯跟着⼀个或多个空⽩字符,⽽后⼜跟了任意⾮空⽩字符的⾏?
egrep ''^#[ ]+[^ ].*'/etc/inittab
3、裁剪access.log中4000-6000⾏,输出⾄new.txt?
sed -n '4000,6000p' > new.txt
4、如何查看file1⽂件的第300-500⾏的内容?
sed -n ‘300,500p’ > file1
5、实现查询⽂件file1⾥⾯空格开始的所在的⾏号?
grep -n '^ [ ]' file1
6、显⽰/etc/inittab中包含了:⼀个数字(即两个冒号中间的⼀个数字)的⾏?
grep -E ':<[0-9]+>:' /etc/inittab
7、如何在⽂本⾥进⾏复制、粘贴、删除⾏,删除全部,按⾏查找和按字⺟查找?
y,p,dd,dG,/STRING,
8、⽂件file1,查询file1⾥空⾏所在的⾏号?打印file1的第2-5⾏?查询file1以hai结尾的⾏?
grep -n '^'file1
sed -n'2,5p'file1
grep 'hai' file1
9、如何查看file1⽂件的第300到500⾏的内容?
cat file1 | head -500|tail -200
10、统计/etc/fstab⽂件中每个单词出现的次数?
cat /etc/fstab | grep -o ‘<[[:alpha:]]*>’|sort | uniq -c|sort -nr
11、⽇志⽂件a.log,内容是时间顺序递增,从0点到23点的所有⽇志记录,每条时间的⽇志为⼀⾏:
2016/06/12 00:00:00 - - 200 190 http://www.a.com/o1html xxxxxxx
2016/06/12 00:00:01 - - 200 390 http://www.b.com/o1html xxxxxxx
2016/06/12 00:00:02 - - 200 490 http://www.v.com/o.html xxxxxxx
2016/06/12 00:00:03 - - 200 890 http://www.a.com/o.html xxxxxxx
…
2016/06/12 23:59:56 - - 200 320 http://www.3.com/o.jpg xxxxxxx
2016/06/12 23:59:57 - - 200 131 http://www.9.com/o.html xxxxxxx
2016/06/12 23:59:58 - - 200 489 http://www.r.com/o.net xxxxxxx
2016/06/12 23:59:59 - - 200 772 http://www.w.com/o.php xxxxxxx
打印出05点到12点之间的所有⽇志?打印出05:30:35到22:45:55之间的所有⽇志?
sed -n ‘/05:30:35/,/22:45:55/p’
12、在档案中搜寻关键词的命令是( )。
A.ps
B.eat
C.more
D.grep
D
13、有3个⽂档file1.out、file2.out、file3.out,⽤⼀个最简单命令将其合并为⼀个⽂档file4.out?
cat file1.out file2.out file3.out > file4.out
14、⼀个⽂本⽂件info.txt的内容如下:
aa,201
zz,502
bb,1
ee,42
每⾏都是按照逗号分隔,其中第⼆列是数⼦,对数⼦进⾏从⼤到⼩排序?
sort -nr -t, -k2
15、可以⼀次显⽰⼀页内容的命令是( )。
a.pause b.cat c.more d.grep
C