Skip to content
Advertisement

ls command ignore specific directory [bash]

Tree:

a.txt (file)
Tests/b.txt (directory)
c.txt (file)

ls :

a.txt
Tests/b.txt
c.txt

Ignore specific file:

ls -I c.txt :

a.txt
Tests/b.txt

Ignore specific directory:

ls -I Tests : (does not work – Tests directory should not appear)

a.txt
Tests/b.txt
c.txt

Advertisement

Answer

The “man page” for the ls command explains that the -I flag accepts a pattern. So you can use a wildcard in your command:

ls -I Tests*

See: man ls or the commands online man page

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement