Shell uses ls to find files and directories

Posted by abasel on Wed, 22 Jan 2020 16:01:22 +0100

Find all directories

ls -F | grep "/$"

-F File type. Indicates that a symbol is added after each enumerated item to mark the File type.

  • / indicates a directory;
  • @Indicates a symbolic link to another file;
  • *Indicates an executable

ls -l -F /usr/lib

Some of the results are as follows:

-rw-r--r--   1 root  wheel    159264  7  4  2018 libtls.15.dylib
-rw-r--r--   1 root  wheel     92032  7  4  2018 libtls.6.dylib
lrwxr-xr-x   1 root  wheel        14  3 28  2018 libtls.dylib@ -> libtls.6.dylib
-rwxr-xr-x   1 root  wheel     65728  7  4  2018 libtzupdate.dylib*
-rwxr-xr-x   1 root  wheel    892608  7  4  2018 libusrtcp.dylib*
-rwxr-xr-x   1 root  wheel     82144  7  4  2018 libutil.dylib*
lrwxr-xr-x   1 root  wheel        13  3 28  2018 libutil1.0.dylib@ -> libutil.dylib
-rwxr-xr-x   1 root  wheel    192784  3 28  2018 libxar.1.dylib*
lrwxr-xr-x   1 root  wheel        14  3 28  2018 libxar.dylib@ -> libxar.1.dylib
-rwxr-xr-x   1 root  wheel     30096  7  4  2018 libxcselect.dylib*
-rwxr-xr-x   1 root  wheel   2280384  7  4  2018 libxml2.2.dylib*
lrwxr-xr-x   1 root  wheel        15  3 28  2018 libxml2.dylib@ -> libxml2.2.dylib
-rwxr-xr-x   1 root  wheel    441904  7  4  2018 libxslt.1.dylib*
lrwxr-xr-x   1 root  wheel        15  3 28  2018 libxslt.dylib@ -> libxslt.1.dylib
-rw-r--r--   1 root  wheel      2040 10  7  2017 liby.a
lrwxr-xr-x   1 root  wheel        12  3 28  2018 libz.1.1.3.dylib@ -> libz.1.dylib
lrwxr-xr-x   1 root  wheel        12  3 28  2018 libz.1.2.11.dylib@ -> libz.1.dylib
lrwxr-xr-x   1 root  wheel        12  3 28  2018 libz.1.2.5.dylib@ -> libz.1.dylib
lrwxr-xr-x   1 root  wheel        12  3 28  2018 libz.1.2.8.dylib@ -> libz.1.dylib
-rwxr-xr-x   1 root  wheel    186432  3 28  2018 libz.1.dylib*
lrwxr-xr-x   1 root  wheel        12  3 28  2018 libz.dylib@ -> libz.1.dylib
drwxr-xr-x  13 root  wheel       416  5  5  2019 log/
drwxr-xr-x  20 root  wheel       640  5  5  2019 pam/
drwxr-xr-x   4 root  wheel       128  2  8  2018 php/
drwxr-xr-x  11 root  wheel       352  3 28  2018 pkgconfig/
lrwxr-xr-x   1 root  wheel        75  3 28  2018 python2.7@ -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7

 

ls -al | grep "^d"

Directories start with d

ls -al | grep "^-"

Files start with -

ls -al ~

Some of the results are as follows

drwxr-xr-x+  53 boweqiang  staff      1696  1 19 15:13 .
drwxr-xr-x    5 root       admin       160 11 14 09:43 ..
drwxr-xr-x    3 boweqiang  staff        96  7  2  2019 .3T
-r--------    1 boweqiang  staff         9  1  1  2018 .CFUserTextEncoding
-rw-r--r--@   1 boweqiang  staff     22532  1 21 09:21 .DS_Store
drwxr-xr-x    8 boweqiang  staff       256  9 11 16:03 .ShadowsocksX-NG
drwx------    2 boweqiang  staff        64 12 24 10:48 .Trash
drwxr-xr-x    6 boweqiang  staff       192 12 17 17:20 .android
drwxr-xr-x   15 boweqiang  staff       480 12 24 10:46 .atom
-rw-------    1 boweqiang  staff     13034 12 24 10:47 .bash_history
-rw-r--r--    1 boweqiang  staff       722 12 17 18:18 .bash_profile
drwx------   42 boweqiang  staff      1344 12 24 10:48 .bash_sessions
drwx------    3 boweqiang  staff        96  5 16  2019 .cups
drwx------    3 boweqiang  staff        96  5  6  2019 .emacs.d
-rw-------    1 boweqiang  staff        47  1 19 15:13 .git-credentials
-rw-r--r--    1 boweqiang  staff       902  6 18  2019 .gitconfig
drwxr-xr-x    4 boweqiang  staff       128 12  9 17:52 .keras
drwxr-xr-x    4 boweqiang  staff       128 12 11 19:19 .m2
drwxr-xr-x    2 boweqiang  staff        64  5 15  2019 .matplotlib
drwxr-xr-x    4 boweqiang  staff       128  6 12  2019 .oracle_jre_usage
drwxr-xr-x    3 boweqiang  staff        96 12 17 11:24 .pip
-rw-------    1 root       staff      5454 12 12 13:01 .sh_history
drwx------    5 boweqiang  staff       160  5  7  2019 .ssh
drwxr-xr-x    8 boweqiang  staff       256 12 17 17:23 .uiautomator2
-rw-------    1 boweqiang  staff     13406 12 17 18:18 .viminfo
drwxr-xr-x    4 boweqiang  staff       128 12 17 17:53 .weditor
-rw-r--r--    1 boweqiang  staff       165 12 10 14:31 .wget-hsts
drwx------@   3 boweqiang  staff        96 12 24 10:51 Applications
drwx------+   5 boweqiang  staff       160 12 17 15:49 Desktop
drwx------+  30 boweqiang  staff       960  1 17 17:40 Documents
drwx------+ 106 boweqiang  staff      3392  1 21 12:38 Downloads
drwx------+  66 boweqiang  staff      2112 12 17 11:40 Library
drwx------+   3 boweqiang  staff        96  1  1  2018 Movies
drwx------+   3 boweqiang  staff        96  1  1  2018 Music
drwx------@   7 boweqiang  staff       224  1  7 13:56 OneDrive
drwx------+  11 boweqiang  staff       352 12 16 16:00 Pictures
drwxr-xr-x+   5 boweqiang  staff       160 12 11 18:44 Public
drwxr-xr-x    6 root       wheel       192 12 17 16:56 androidsdk
drwxr-xr-x    5 root       wheel       160 12 11 19:45 ant-install
-rw-r--r--    1 boweqiang  staff   6066412 12 13 10:33 ant-install.tar.gz

 

Published 14 original articles, won praise 3, visited 979
Private letter follow

Topics: PHP Python Android git