How can I exclude a directory from ls command

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/


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?


Try these:

ls -la | egrep -v ^d

-or-

ls -p | egrep -v /$

-or-

find . -type f -maxdepth 1

Tags:

Linux

Unix