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服务进程

     

      

     

  • 相关阅读:
    创建pycharm项目时项目解释器的选择
    chrome插件网站
    在chrome中屏蔽百度推荐
    annotation使用示例
    scala编程第16章学习笔记(3)——List类的高阶方法
    Eclipse常用快捷键
    Ubuntu常用命令
    scala编程第16章学习笔记(2)
    scala编程第16章学习笔记(1)
    scala编程第15章
  • 原文地址:https://www.cnblogs.com/zoulongbin/p/9913619.html
Copyright © 2011-2022 走看看