答案就在下一行,鼠標選中就看到了
像這樣
像這樣
Linux面試題
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
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