zoukankan      html  css  js  c++  java
  • 测试

     

    ls  命令

     

    描述

    ls - list directory contents

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

     

    格式

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

    参数

    参数 参数描述 备注
    -l use a long listing format 长格式
    -r reverse order while sorting 相反排序(升序排序)
    -h sort by modification time 相反排序(升序排序)
    -d list directory entries instead of contents, and do not dereference symbolic links  
    -t with –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/
    / /'
    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服务进程

     

      

     

  • 相关阅读:
    git 学习
    公司领导写给新员工的信
    PLSQl远程连接oracle数据库
    hdu2222之AC自动机入门
    代码中添加事务控制 VS(数据库存储过程+事务) 保证数据的完整性与一致性
    ubuntu13.04安装SenchaArchitect-2.2无法启动的问题
    MVVMLight Toolkit在Windows Phone中的使用扩展之一:在ViewModel中实现导航,并传递参数
    面试题24:二叉搜索树与双向链表
    Struts2中的包的作用描述
    filter-mapping中的dispatcher使用
  • 原文地址:https://www.cnblogs.com/zoulongbin/p/9913619.html
Copyright © 2011-2022 走看看