[linux] How to exclude a directory in find . command

#find command in linux
def : find command used to locate /search files in unix /linux system ,
      find  search for files in a directory hierarchy
1)exec   Show diagnostic information relating to -exec, -execdir, -ok and -okdir
2)-options
  -H =do not follow symoblic links while except while procesing .
  -L = follow symbolic links
  -P =never follow symbolic links

  -type c
             File is of type c:

             b      block (buffered) special

             c      character (unbuffered) special

             d      directory

             p      named pipe (FIFO)

             f      regular file

             l      symbolic  link;  this  is  never true if the -L option or the -follow option is in effect, unless the
                    symbolic link is broken.  If you want to search for symbolic links when -L is in effect, use -xtype.

             s      socket

             D      door (Solaris)

    -Delete
    Delete files; true if removal succeeded.  If the removal failed, an error message  is  issued.
    If  -delete
    #fails, find's exit status will be nonzero (when it eventually exits).


find /home/mohan/a -mindepth 3 -maxdepth 3 -type f -name "*.txt" |xargs rm -rf
find -type d -name
find -type f -Name
find /path/ -type f -iname (i is case insenstive)

#find directores a/b/c and only delete c directory inside have "*.txt "
find /home/mohan/a -mindepth 3 -maxdepth 3 -type f -name "*.txt" |xargs rm -rf
find /home/mohan/a -mindepth 3 -maxdepath 3 -type f -name "*.txt" -delete


#delete particular directory have empty file and only  we can delete empty files
find /home/mohan -type f -name "*.txt" -empty -DELETE


#find multiple files and also find empty files
find /home/mohan -type f \( -name "*.sh" -o  -name "*.txt" \) -empty

#delete empty files two or more Files
find /home/mohan -type f \( -nmae "*.sh" -o -name "*.txt" \) -empty -delete


#How to append contents of multiple files into one file
find . -type f -name '*.txt' -exec cat {} + >> output.file

#last modified files finding using less than 1 min (-n)
ls -lrth|find . -type f -mmin -1

#last modified files more than 1 min (+n)
ls -lrth|find . -type f -mmin +1


#last modified files exactly one mins
find . -type f -mmin 1

last modifiedfiles exactly in one day by using command (-mtime)
find . -type f -mtime 10

#last modified more than 10 days
find . -type  f -mtime +10

#last modified less than 10 days
find . -type f -mtime -10

#How to Find Modified Files and Folders Starting from a Given Date to the Latest Date
find . -type f  -newermt "17-11-2020"

#How to Find a List of “sh” Extension Files Accessed in the Last 30 Days--- -matdimtype
ls -lrt|find . -type f -iname ".sh" -atime -30

#How to Find a List of Files Created Today, -1 means less than min,
ls -lrt | find . -type f -ctime -1 -ls

Examples related to linux

grep's at sign caught as whitespace How to prevent Google Colab from disconnecting? "E: Unable to locate package python-pip" on Ubuntu 18.04 How to upgrade Python version to 3.7? Install Qt on Ubuntu Get first line of a shell command's output Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? Run bash command on jenkins pipeline How to uninstall an older PHP version from centOS7 How to update-alternatives to Python 3 without breaking apt?

Examples related to shell

Comparing a variable with a string python not working when redirecting from bash script Get first line of a shell command's output How to run shell script file using nodejs? Run bash command on jenkins pipeline Way to create multiline comments in Bash? How to do multiline shell script in Ansible How to check if a file exists in a shell script How to check if an environment variable exists and get its value? Curl to return http status code along with the response docker entrypoint running bash script gets "permission denied"

Examples related to find

Find a file by name in Visual Studio Code Explaining the 'find -mtime' command find files by extension, *.html under a folder in nodejs MongoDB Show all contents from all collections How can I find a file/directory that could be anywhere on linux command line? Get all files modified in last 30 days in a directory FileNotFoundError: [Errno 2] No such file or directory Linux find and grep command together find . -type f -exec chmod 644 {} ; Find all stored procedures that reference a specific column in some table