• Shell学习——列出当前路径下所有目录


    1、ls -d */
    [root@client02 ~]# ls -d */
    Desktop/ Documents/ Downloads/ jq-1.5/ Music/ Pictures/ Public/ Templates/ Videos/ zookeeper/
    [root@client02 ~]#
    2、ls -F | grep /$
    [root@client02 ~]# ls -F | grep '/$'
    Desktop/
    Documents/
    Downloads/
    jq-1.5/
    Music/
    Pictures/
    Public/
    Templates/
    Videos/
    zookeeper/
    [root@client02 ~]#
    -F:附加文件类别:符号在文件名最后,/表明是一个目录;@表明是符号链接;*表明是一个可执行文件。
    3、ls -l|grep ^d
    [root@client02 ~]# ls -l|grep ^d
    drwxr-xr-x. 2 root root 6 Apr 17 2017 Desktop
    drwxr-xr-x. 2 root root 6 Apr 17 2017 Documents
    drwxr-xr-x. 2 root root 6 Apr 17 2017 Downloads
    drwxr-xr-x. 9 1002 1002 4096 Aug 19 19:53 jq-1.5
    drwxr-xr-x. 2 root root 6 Apr 17 2017 Music
    drwxr-xr-x. 2 root root 6 Apr 17 2017 Pictures
    drwxr-xr-x. 2 root root 6 Apr 17 2017 Public
    drwxr-xr-x. 2 root root 6 Apr 17 2017 Templates
    drwxr-xr-x. 2 root root 6 Apr 17 2017 Videos
    drwxr-xr-x. 4 root root 29 Apr 11 20:08 zookeeper
    [root@client02 ~]#
    4、find . -maxdepth 1 -type d -print
    [root@client02 ~]# find . -maxdepth 1 -type d -print
    .
    ./.cache
    ./.dbus
    ./.config
    ./.ssh
    ./Desktop
    ./Downloads
    ./Templates
    ./Public
    ./Documents
    ./Music
    ./Pictures
    ./Videos
    ./.local
    ./.ansible
    ./zookeeper
    ./jq-1.5
    ./.pki
    [root@client02 ~]#

  • 相关阅读:
    二叉树的层序遍历-102
    剑指offer 06 从尾到头打印链表
    替换空格:剑指offer05
    面试题16.11.跳水板----leetcode
    JVM——垃圾回收
    新生代Eden与两个Survivor区的解释
    JVM 1.8 永久代---元空间 的变动
    Git拉取项目避坑
    python-装饰器
    python-Queue
  • 原文地址:https://www.cnblogs.com/pigwan7/p/9629315.html
Copyright © 2020-2023  润新知