Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I exclude a directory from ls command

Tags:

linux

unix

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

like image 576
Madhumitha Avatar asked Aug 13 '15 22:08

Madhumitha


People also ask

How do you exclude a directory?

Go to Start > Settings > Update & Security > Windows Security > Virus & threat protection. Under Virus & threat protection settings, select Manage settings, and then under Exclusions, select Add or remove exclusions. Select Add an exclusion, and then select from files, folders, file types, or process.

How do I exclude a directory in find command?

To exclude multiple directories, OR them between parentheses. And, to exclude directories with a specific name at any level, use the -name primary instead of -path .

How do I exclude a folder in a tree?

tree displays the directory structure of the current directory. -d option displays only directories. -I option allows to exclude directories that match specific pattern e.g. In order to exclude multiple directories at once, their names must be separated by | sign, i.e.

How do you use exclude in Linux?

Exclude Files and Directories from a List. When you need to exclude a large number of different files and directories, you can use the rsync --exclude-from flag. To do so, create a text file with the name of the files and directories you want to exclude. Then, pass the name of the file to the --exlude-from option.


1 Answers

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?

like image 162
Shawn Balestracci Avatar answered Sep 21 '22 11:09

Shawn Balestracci