Let say we have
Scripts
Test
Test1
When we do ls
it shows all the three directories but I need to exclude the test1
.
So I should get only
Scripts
Test
What command should I use here to exclude a directory?
Thanks in advance
Let say we have
Scripts
Test
Test1
When we do ls
it shows all the three directories but I need to exclude the test1
.
So I should get only
Scripts
Test
What command should I use here to exclude a directory?
Thanks in advance
ls -ITest1
from man ls
:
-I, --ignore=PATTERN
do not list implied entries matching shell PATTERN
You can use it multiple times like:
ls -ITest1 -ITest2
or you could use a matching pattern:
ls -ITest?
You can do this via grep -v
. Command will be ls /mydir/ | grep -v 'test1'
The -v
means exclude.
Good references here: http://www.thegeekstuff.com/2011/10/grep-or-and-not-operators/
Try these:
ls -la | egrep -v ^d
-or-
ls -p | egrep -v /$
-or-
find . -type f -maxdepth 1