linux ls only shows files or folders

Only show folders ls -l | grep ^d

Only show files ls -l | grep ^-


Explain:

After ls -l, you will get the following content
drwx------ 4 jinwang users 4096 2012-02-09 15 :00 .xchat2

-rw-r--r-- 1 jinwang users 1690399 2012-06-04 12:16 45s.txt


file starts with "-", the folder is d, so this is the content of the following grep.

^ is the position where the regular expression matches the input string.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326361870&siteId=291194637