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
- How do I deal with a filename that starts with the hyphen (-) character?
- Bash: No such file or directory?
- What’s a .sh file?
- How to unmount a busy device
- How to unmount a busy device
- No space left on device
- gcc: error: unrecognized command line option
- How to set proxy for wget?
- How to change permissions for a folder and its subfolders/files in one step
- Docker can’t connect to docker daemon
- Need a good hex editor for Linux
- Who can access a file with octal permissions “000” on Linux/UNIX?
- How to open some ports on Ubuntu?
- Trying to use bash on Windows and got no installed distributions message
- “Unable to find remote helper for ‘https'” during git clone
- Bash script: bad interpreter
- tar: Cowardly refusing to create an empty archive
- How can I delete a user in linux when the system says its currently used in a process
- Read and write to binary files in C?
- Can’t remove a directory in Unix
- C fopen vs open
- Why does “docker attach” hang?
- Retrieve last 100 lines logs
- What are various options / arguments for “./configure” in Linux
- How to include file in a bash shell script
- CronJob not running
- Delete .DS_STORE files in current folder and all subfolders from command line on Mac
- How to configure WP filesystem access in Linux (Ubuntu Server)?
- Can’t upload media to my Raspberry Pi WordPress server
- My WordPress is giving me an 403 error when saving post/draft with specific words
- How to run a server on port 80 as a normal user on Linux?
- Copying a large directory tree locally? cp or rsync?
- Check if port is open or closed on a Linux server?
- Moving an already-running process to Screen
- When does `cron.daily` run?
- Permission denied (publickey). SSH from local Ubuntu to Amazon EC2 server
- How to run a command multiple times, using bash shell?
- LVM dangers and caveats
- How to reconnect to a disconnected ssh session
- Should I quit using Ifconfig?
- How to know from which yum repository a package has been installed?
- SSL Certificate Location on UNIX/Linux
- tar – Remove leading directory components on extraction
- Keeping a linux process running after I logout
- Force dig to resolve without using cache
- How to list Apache enabled modules?
- How to forcibly close a socket in TIME_WAIT?
- How can I monitor hard disk load on Linux?
- What’s the reverse DNS command line utility?
- How to add a security group to a running EC2 Instance?
- How bad is it really to install Linux on one big partition?
- How do I extract login history?
- SSH from A through B to C, using private key on B [closed]
- Is it possible to reboot a Linux OS without rebooting the hardware?
- Does the “bs” option in “dd” really improve the speed?
- What solutions exist to allow the use of revision control for server configuration files? [closed]
- Dump a linux process’s memory to file
- What is the difference between /sbin/nologin and /bin/false?