测试

 

ls  命令

 

描述

ls - list directory contents

List information about the FILEs (the current directory by default).

 

格式

ls   [option] ......    [file]  ......

 

参数

参数参数描述备注
-luse a long listing format长格式
-rreverse order while sorting相反排序(升序排序)
-hsort by modification time相反排序(升序排序)
-dlist directory entries instead of contents, and do not dereference symbolic links 
-twith –l ,print sizes in human readable format相反排序(升序排序)


 

 

 

 

 

 

 

实例

 

范例1:列出目前工作目录下所有名称是 s 开头的文件,越新的排越后面

 1 显示行号操作
 2 
 3 [root@oldgirl ~]# echo stu{01..02} | xargs -n 1 > text.txt
 4 
 5 [root@oldgirl ~]# echo  >> text.txt
 6 
 7 [root@oldgirl ~]# echo stu06 >> text.txt
 8 
 9 [root@oldgirl ~]# cat -n text.txt
10 
11 1       stu01
12 
13 2       stu02
14 
15 3      
16 
17 4       stu06
18 
19 [root@oldgirl ~]# awk '{print NR,$0}' text.txt
20 
21 1 stu01
22 
23 2 stu02
24 
25 3
26 
27 4 stu06
28 
29 [root@oldgirl ~]# sed = text.txt | sed 'N;s/\n/ /'
30 
31 1 stu01
32 
33 2 stu02
34 
35 3
36 
37 4 stu06
38 
39 [root@oldgirl ~]# nl text.txt
40 
41 1       stu01
42 
43 2       stu02
44 
45  
46 
47 3       stu06
48 
49 [root@oldgirl ~]# grep -n . text.txt
50 
51 1:stu01
52 
53 2:stu02
54 
55 4:stu06
56 
57 [root@oldgirl ~]# grep -n ".*" text.txt
58 
59 1:stu01
60 
61 2:stu02
62 
63 3:
64 
65 4:stu06
显示行号操作

 

范例2:列出目前工作目录下所有名称是 s 开头的文件,越新的排越后面

 1 [root@oldgirl ~]# ps -ef|grep sshd
 2 root       1547      1  0 Oct30 ?        00:00:00 /usr/sbin/sshd
 3 root       5709   1547  0 09:27 ?        00:00:01 sshd: root@pts/0 
 4 root       5949   1547  0 13:35 ?        00:00:00 sshd: root@pts/1 
 5 root       6370   1547  0 16:03 ?        00:00:00 sshd: root@pts/2 
 6 root       6617   6372  0 17:24 pts/2    00:00:00 grep sshd
 7 [root@oldgirl ~]# ps -ef|grep  "/sshd"
 8 root       1547      1  0 Oct30 ?        00:00:00 /usr/sbin/sshd
 9 root       6619   6372  0 17:25 pts/2    00:00:00 grep /sshd
10 [root@oldgirl ~]# ps -ef|grep  "/sshd" | grep -v grep
11 root       1547      1  0 Oct30 ?        00:00:00 /usr/sbin/sshd
12 [root@oldgirl ~]# ps -ef|grep  "/sshd" | grep -v grep | wc -l
13 1
14 [root@oldgirl ~]#
查看ssh服务进程

 

  

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值