每天⼀个Linux命令(13)less命令
less命令的作⽤与more⼗分相似,都可以⽤来浏览⽂字档案的内容,不同的是less命令允许⽤户向前或向后浏览⽂
件,⽽more命令只能向前浏览。
⽤less命令显⽰⽂件时,⽤PageUp键向上翻页,⽤PageDown键向下翻页。要退出less程序,应按Q键。
(1)⽤法:
⽤法:less[选项参数][⽂件参数]
(2)功能:
功能:less与more命令类似,但可以通过翻页键查看上下页的内容
(3)选项参数:
1)-e:⽂件内容显⽰完毕后,⾃动退出
2)-f:强制显⽰⽂件
3)-g:不加亮显⽰搜索到的所有关键词,仅显⽰当前显⽰的关键字,以提⾼显⽰速度
4)-l:搜索时忽略⼤⼩写的差异
5)-N:每⼀⾏⾏⾸显⽰⾏号
6)-s:将连续多个空⾏压缩成⼀⾏显⽰
7)-S:在单⾏显⽰较长的内容,⽽不换⾏显⽰
8)-x<数字>:将TAB字符显⽰为指定个数的空格字符。
(4)实例:
1)[root@localhostDocuments]#lessless_text在另⼀个进程页⾯中显⽰⽂本内容,按q键退出
[root@localhostDocuments]#mvmore_text1less_text//将more_text1改名为less_text
[root@localhostDocuments]#ll
总⽤量4
-rw-r--r--.1rootroot6645⽉907:59less_text
[root@localhostDocuments]#catless_text//在当前终端中显⽰(和less命令显⽰的效果还是有差别的)
[root@localhostDocuments]#lessless_text//在另⼀个页⾯中显⽰⽂本
IamstudingordersofLinux!
Iamtryingtowriteasmanyaslinesoftext!
Nomatterhowlowyouconsideryourlf,
thereisalwayssomeonelookingbehindyou,
hopingthattheywerethathigh!
Somethingyouwantkeepallthetime,alwaysyouwilllo!
Neverforgettosay"thanks"!
Hppaytoday,also,preparedforhappinessinthefuture!
Don'taimyoursuccessifyouwantit,justdowhatyouloveandbelieveandfinallyyouwillsuccess!
Maybeyoucanbelazemanlikeapig,butyoucan'tfeelfreeasit!
Iamacollegeschoolstudent!
Iamplanningtoliveandworkinhangzhouorguangzhou!
Iamfromhefeianhui!
Enough,Ihavewritetoomanywords!
(END)
2)[root@localhostDocuments]#ps-ef|less显⽰已有进程信息
IDPIDPPIDCSTIMETTYTIMECMD
root10000:16?00:00:10/usr/lib/systemd/systemd--switched-root--system--derialize24
root20000:16?00:00:00[kthreadd]
root32000:16?00:00:03[ksoftirqd/0]
root52000:16?00:00:00[kworker/0:0H]
root72000:16?00:00:00[migration/0]
root82000:16?00:00:00[rcu_bh]
root92000:16?00:00:00[rcuob/0]
root102000:16?00:00:00[rcuob/1]
root112000:16?00:00:00[rcuob/2]
root122000:16?00:00:00[rcuob/3]
root132000:16?00:00:00[rcuob/4]
root142000:16?00:00:00[rcuob/5]
root152000:16?00:00:00[rcuob/6]
root162000:16?00:00:00[rcuob/7]
root172000:16?00:00:00[rcuob/8]
root182000:16?00:00:00[rcuob/9]
root192000:16?00:00:00[rcuob/10]
root202000:16?00:00:00[rcuob/11]
root212000:16?00:00:00[rcuob/12]
root222000:16?00:00:00[rcuob/13]
root232000:16?00:00:00[rcuob/14]
root242000:16?00:00:00[rcuob/15]
root252000:16?00:00:00[rcuob/16]
root262000:16?00:00:00[rcuob/17]
root272000:16?00:00:00[rcuob/18]
root282000:16?00:00:00[rcuob/19]
root292000:16?00:00:00[rcuob/20]
root302000:16?00:00:00[rcuob/21]
root312000:16?00:00:00[rcuob/22]
root322000:16?00:00:00[rcuob/23]
root332000:16?00:00:00[rcuob/24]
root342000:16?00:00:00[rcuob/25]
root352000:16?00:00:00[rcuob/26]
:
.......//还有很多没有显⽰
3)[root@localhostDocuments]#history|less显⽰历史输⼊的进程信息
1touchtouch_test/home/sunjimeng/Document
2cd/home/sunjimeng/Document
3ll
4cd/
5touchtouch_text/home/sunjimeng/Document/touch_test
6cd/home/sunjimeng/Document
7ll
8rmtouch_test
9cd/
10ls-l/home/sunjimeng/Document
11touch/home/sunjimeng/Document/touch_test_file
12cdhome/sunjimeng/Document
13ll
14touchtouch_test_file
15ll
16touch-t06061806touch_test_file
17ll
18touchtouch_test_file
19ll
20touch-t06061806touch_test_file
21ll
22touchtouch_test_file2
23ll
24touch-rtouch_testfiletouch_test_tile2
25touch-rtouch_test_filetouch_test_file2
26ll
27touch-d"10dayago"touch_test_file2
28ll
29touch-rtouch_test_filetouch_test_file2
30ll
31touch-d"10daysago"touch_test_file2
32ll
33touch"10daysago"touch_test_file
34ll
:
4)[root@localhostDocuments]#lessless1less2查看多个⽂件(怎么切换下⼀个还不清楚)
root@localhostDocuments]#cat>less1<
>LostmeansGet!
>
>NolosingNogetting!
>
>End!
>EOF
[root@localhostDocuments]#cat>less2<
>Ifyouwantkeep,youalwayslo!
>
>CertainlyItis!
>End!
>EOF
[root@localhostDocuments]#ll
总⽤量12
-rw-r--r--.1rootroot455⽉908:15less1
-rw-r--r--.1rootroot575⽉908:16less2
-rw-r--r--.1rootroot6645⽉907:59less_text
[root@localhostDocuments]#lessless1less2
LostmeansGet!
NolosingNogetting!
End!
less1(file1of2)(END)-Next:less2
5)[sunjimeng@localhost~]$netstat-tpnl|less在另⼀个进程页⾯中分页显⽰信息,这⾥显⽰的是⽹络信息
[sunjimeng@localhost~]$netstat-tpnl|less
(Notallprocesscouldbeidentified,non-ownedprocessinfo
willnotbeshown,youwouldhavetoberoottoeitall.)
ActiveInternetconnections(onlyrvers)
ProtoRecv-QSend-QLocalAddressForeignAddressStatePID/Programname
tcp000.0.0.0:220.0.0.0:*LISTEN-
tcp00127.0.0.1:6310.0.0.0:*LISTEN-
tcp00127.0.0.1:250.0.0.0:*LISTEN-
tcp600:::22:::*LISTEN-
tcp600::1:631:::*LISTEN-
tcp600::1:25:::*LISTEN-
(5)其他:
1.全屏导航
ctrl+F-向前移动⼀屏
ctrl+B-向后移动⼀屏
ctrl+D-向前移动半屏
ctrl+U-向后移动半屏
2.单⾏导航
j-向前移动⼀⾏
k-向后移动⼀⾏
3.其它导航
G-移动到最后⼀⾏
g-移动到第⼀⾏
q/ZZ-退出less命令
4.其它有⽤的命令
v-使⽤配置的编辑器编辑当前⽂件
h-显⽰less的帮助⽂档
&pattern-仅显⽰匹配模式的⾏,⽽不是整个⽂件
5.标记导航
当使⽤less查看⼤⽂件时,可以在任何⼀个位置作标记,可以通过命令导航到标有特定标记的⽂本位置:
ma-使⽤a标记⽂本的当前位置
'a-导航到标记a处
本文发布于:2022-12-26 23:42:12,感谢您对本站的认可!
本文链接:http://www.wtabcd.cn/fanwen/fan/90/36785.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |