Use the -prune
primary. For example, if you want to exclude ./misc
:
find . -path ./misc -prune -o -name '*.txt' -print
To exclude multiple directories, OR them between parentheses.
find . -type d \( -path ./dir1 -o -path ./dir2 -o -path ./dir3 \) -prune -o -name '*.txt' -print
And, to exclude directories with a specific name at any level, use the -name
primary instead of -path
.
find . -type d -name node_modules -prune -o -name '*.json' -print
Related Posts:
- How to exclude a directory in find . command
- How do I find all files containing specific text on Linux?
- How can I recursively find all files in current and subfolders based on wildcard matching?
- How to perform grep operation on all files in a directory?
- subprocess.Popen(): OSError: [Errno 8] Exec format error in python?
- How to substitute shell variables in complex text files
- How can I recursively find all files in current and subfolders based on wildcard matching?
- Curl command for https ( SSL )
- “sed” command in bash
- How can I find all *.js file in directory recursively in Linux?
- Shell command to tar directory excluding certain files/folders
- Explaining the ‘find -mtime’ command
- Pseudo-terminal will not be allocated because stdin is not a terminal
- Given two directory trees, how can I find out which files differ by content?
- Diff command along with Grep gives “Binary file (standard input) matches”
- Pseudo-terminal will not be allocated because stdin is not a terminal
- screen Cannot open your terminal ‘/dev/pts/0’ – please check
- ./configure : /bin/sh^M : bad interpreter
- How to use regex with find command?
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- Is there a “goto” statement in bash?
- Implementing shell in C and need help handling input/output redirection
- Command to change the default home directory of a user
- Writing a simple shell in C using fork/execvp
- Implementation of multiple pipes in C
- chmod: changing permissions of ‘my_script.sh’: Operation not permitted
- What does “&” at the end of a linux command mean?
- What does set -e mean in a bash script?
- What does set -e mean in a bash script?
- Syntax error near unexpected token ‘then’
- “find: paths must precede expression:” How do I specify a recursive search that also finds files in the current directory?
- How to use sed to extract substring
- How do I know the script file name in a Bash script?
- Shell command to monitor changes in a file
- What is “-bash: !”: event not found”
- What does ‘set -e’ do, and why might it be considered dangerous?
- How to add a timestamp to bash script log?
- Colors in bash after piping through less?
- How can I kill all stopped jobs?
- How to run command as user who has /usr/sbin/nologin as Shell?
- Is there a way to do a remote “ls” much like “scp” does a remote copy?
- How do I join two named pipes into single input stream in linux
- What’s a .sh file?
- How to fix ‘sudo: no tty present and no askpass program specified’ error?
- What does pss mean in /proc/pid/smaps
- apt-get error: Sub-process /usr/bin/dpkg returned an error code (1)
- error: ‘Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)’ — Missing /var/run/mysqld/mysqld.sock
- How do I grep recursively?
- How to extract C source code from .so file?
- WSL – GEDIT Unable to init server: Could not connect: Connection refused
- Install tkinter for Python
- Creating a new directory in C
- Uncompress tar.gz file
- curl: (6) Could not resolve host: google.com; Name or service not known
- How to pass password to scp?
- scp gives “not a regular file”
- dquote> result of a execution a program in linux shell
- CentOS error – sudo: effective uid is not 0, is sudo installed setuid root?
- Merge / convert multiple PDF files into one PDF
- scp from Linux to Windows
- What is the difference between /etc/rc.local and ~/.bashrc?
- Snort Message – WARNING: No preprocessors configured for policy 0
- How do I find the MySQL my.cnf location
- node.js: cannot find module ‘request’
- What is the reason and how to avoid the [FIN, ACK] , [RST] and [RST, ACK]
- wget returns “Unable to establish SSL connection”
- how to check which version of nltk, scikit learn installed?
- Copy multiple files from one directory to another from Linux shell
- Apache server keeps crashing, “caught SIGTERM, shutting down”
- execvp: bad address error
- error : storage class specified for parameter
- How do I write stderr to a file while using “tee” with a pipe?
- tar: Error is not recoverable: exiting now
- python-dev installation error: ImportError: No module named apt_pkg
- WordPress Update – This is usually due to inconsistent file permissions.: wp-admin/includes/update-core.php
- how to properly mount external server directory for wordpress uploads
- Anyone else experiencing high rates of Linux server crashes during a leap second day?
- What permissions should my website files/folders have on a Linux webserver?
- Can I automatically add a new host to known_hosts?
- Can I nohup/screen an already-started process?
- How can I run Debian stable but install some packages from testing?
- Environment variables of a running process on Unix?
- In my /etc/hosts/ file on Linux/OSX, how do I do a wildcard subdomain?
- Meaning of the buffers/cache line in the output of free
- How to cd into a directory with this name “-2” (starting with the hyphen)?
- how to disable SSH login with password for some users?
- Difference in sites-available vs sites-enabled vs conf.d directories (Nginx)?
- Is it possible to detach a process from its terminal? (Or, “I should have used screen!”) [duplicate]
- Disk full, du tells different. How to further investigate?
- Filename length limits on linux?
- best way to clear all iptables rules
- How can I rename a Unix user?
- How to re-order windows, change the scroll shortcut, and modify the status bar contents in GNU Screen?
- How to prevent a user from login in, but allow “su – user” in Linux?
- I have a keypair. How do I determine the key length?
- Why drop caches in Linux?
- swap partition vs file for performance?
- Best way to disable swap in Linux
- How can I zip/compress a symlink?
- How to find the physical volume(s) that hold a logical volume in LVM