![](/img/trans.png)
[英]How can I ignore the contents of /proc directory from the output of ls -lR command
[英]How can I exclude a directory from ls command
讓我們說
Scripts
Test
Test1
當我們做ls
它顯示了所有三個目錄,但我需要排除test1
。 所以我應該只得到
Scripts
Test
我應該在這里使用什么命令來排除目錄?
提前致謝
ls -ITest1
來自man ls
:
-I, --ignore=PATTERN
do not list implied entries matching shell PATTERN
你可以多次使用它,如:
ls -ITest1 -ITest2
或者你可以使用匹配的模式:
ls -ITest?
你可以通過grep -v
來做到這一點。 命令將是ls /mydir/ | grep -v 'test1'
ls /mydir/ | grep -v 'test1'
-v
表示排除。
這里有很好的參考: http : //www.thegeekstuff.com/2011/10/grep-or-and-not-operators/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.