How can we exclude given directory and sub-directories from getting listed using the find command

Here is my directory structure:

/dir_a
     -- /dir_1
        ---/file_11
     -- /dir_2
        ---/file_21
        ---/file_22
     -- /dir_3
        ---/file_31
        ---/file_32

I want to print the output in the file as -

/dir_a/dir_1/file_11
/dir_a/dir_2
/dir_a/dir_3/file_31
/dir_a/dir_3/file_31

I tried with the fine command:

find /dir_a/ -not -path /dir_a/dir_2/* >output.txt

I don't want /dir_a/dir_2 in the output.

What could be the way?



from Recent Questions - Stack Overflow https://ift.tt/3BF1hDL
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)