Introduction to the -path -prune parameter in the Linux find command

  
                

The find command in Linux has multiple ways to find it. What about the -path -prune parameter in the find command? The following small series will introduce you to the usage of -path -prune in the find command.

If you find the file in the current directory, and there are a lot of files and directories (multi-layer directory) under the current directory, including dir0, dir1 and dir2. . . Such as the directory and dir00, dir01. .dir10, dir11. . Subdirectories.

1. Find all txt suffix files

find in the current directory. /-name *.txt

2. Find the txt suffix file

find in the dir0 directory and subdirectory under the current directory. /-path ‘. /dir0*’ -name *.txt

3. Find the txt suffix file

find in the subdirectory dir00 and its subdirectories under the dir0 directory in the current directory. /-path ‘*dir00*’ -name *.txt

4. Find the txt suffix file

find in a directory other than dir0 and subdirectories. /-path ‘. /dir0*’ -a -prune -o -name *.txt -print

Description: -a should be an abbreviation for and, meaning logical operator ‘ or & rsquo; (&&) ; -o should be an abbreviation for or, meaning logical operator ‘ & & rsquo; (

Copyright © Windows knowledge All Rights Reserved