nl
stringlengths
13
387
bash
stringlengths
1
532
Search for the extended regex expanded by"$MONTH\/$YEAR.*GET.*ad=$ADVERTISER HTTP\/1" in the decompressed contents of the /var/log/apache2/access*.gz files that are newer than ./tmpoldfile and older than ./tmpnewfile
find /var/log/apache2/access*.gz -type f -newer ./tmpoldfile ! -newer ./tmpnewfile \ | xargs zcat | grep -E "$MONTH\/$YEAR.*GET.*ad=$ADVERTISER HTTP\/1" -c
search for the file "abc" in the current folder or display all the directories
find . -name abc -or -type d
Search for file "file" between level 2 and 3 of the directory tree
find -mindepth 2 -maxdepth 3 -name file
search for the file "file" in current folder and save the output to the same file
find -name file -fprint file
search for the file "file" in the current folder excluding those in the sub directory ".git"
find . -path ./.git -prune -o -name file -print
Search for file "file" with minimum depth set to 4
find -mindepth 4 -name file
search for the file "file1" in the entire file system
find / -name file1
search for the file "file_name" in the folder /path
find /path -name file_name
search for the file "filename" in the entire file system
find / -name filename
search for the files "foo.txt" in the current folder
find . -name foo.txt
search for the files "foo.txt" in the current folder and rename it to foo.xml
find -name foo.txt -execdir rename 's/\.txt$/.xml/' '{}' ';'
search for the file "myletter.doc" in the home folder
find ~ -name myletter.doc -print
search for the file "process.txt" in the current directory
find . -name "process.txt"
search for the file "process.txt" in the current folder (case insensitive search)
find . -iname 'process.txt' -print
search for the file "process.txt" in the entire file system
find / -name "process.txt"
search for the file "process.txt" in the entire file system (case insensitive search)
find / -iname 'process.txt' -print
Search for files/directories named 'fileName.txt' under '/path/to/folder' directory tree without traversing into directories that contain the string 'ignored_directory' in their paths
find /path/to/folder -path "*/ignored_directory" -prune -o -name fileName.txt -print
Search for files/directories named 'fileName.txt' under current directory tree without traversing into './ignored_directory'
find . -path ./ignored_directory -prune -o -name fileName.txt -print
Search for the files/directories that were modified more than an hour ago
find . -mtime +1
Search for files/directories which are writable by both their owner and their group
find . -perm -220
Search for files/directories which are writable by both their owner and their group
find . -perm -g+w,u+w
Search for files/directories which are writable by either their owner or their group
find . -perm /220
Search for files/directories which are writable by either their owner or their group
find . -perm /u+w,g+w
Search for files/directories which are writable by either their owner or their group
find . -perm /u=w,g=w
Search for files/directories which are writable by somebody (their owner, or their group, or anybody else)
find . -perm /222
Search for files/directories which have read and write permission for their owner, and group and only read permission for others
find . -perm -664
Search for files/directories which have read and write permission for their owner, and group and only read permission for others
find . -perm 664
Search for files/directories with a case insensitive .txt extension in entire file system
find / -iname '*.txt'
Search for files/directories with the case insensitive pattern anaconda* in /var/log
find /var/log/ -iname anaconda*
Search for files/directories with the case insensitive pattern anaconda.* in /var/log
find /var/log/ -iname anaconda.*
Search for files/directories with the case insensitive pattern anaconda.* in /var/log directory and create an archive (file.tar) of the last file found
find /var/log/ -iname anaconda.* -exec tar -cvf file.tar {} \;
Search for files/directories with the case insensitive pattern anaconda.* in var/log directory
find var/log/ -iname anaconda.*
Search for files/directories with the case insensitive pattern anaconda.* in var/log directory and create an archive (file.tar) of all the files found
find var/log/ -iname "anaconda.*" -exec tar -rvf file.tar {} \;
Search for files/directories with the case insensitive pattern anaconda.* in var/log directory and create an archive (somefile.tar) of all the files found
tar -cvf file.tar `find var/log/ -iname "anaconda.*"`
Search for files/directories with the case insensitive pattern anaconda.* in var/log directory and create an archive (file1.tar) of the last block of files sent to xargs
find var/log/ -iname anaconda.* | xargs tar -cvf file1.tar
Search for files/directories with the case insensitive pattern anaconda.* in var/log directory and create an archive (file.tar) of the last file found
find var/log/ -iname anaconda.* -exec tar -cvf file.tar {} \;
Search for files bigger than 10M
find ~ -size +10M
search for files cart4 or cart5 or cart6 in the folder junk which is in home folder and delete it.
find ~/junk -name 'cart[4-6]' -exec rm {} \;
search for the file centos in /usr folder ( case insenstive search )
find /usr -iname centos
search for the file chapter1 in the folder /work
find /work -name chapter1
search for the file filename in the entire file system
find / -name filename
search for the file, filename.txt in the current folder
find . -name filename.txt
search for the file, filename.txt in the current folder ( case insensitive search )
find . -iname filename.txt
search for the file foo.txt in the entire file system
find / -name foo.txt
Search for files greater than 20MB under your home directory (/home/user)
find ~ -size +20M
search for files in the current folder ending with ".au"
find -type f -name '*.au'
search for files in current folder using regular expressions
find ./ -regex '.*\..*'
search for the files in the current folder which begin with the word "kt" followed by a digit
find . -name 'kt[0-9] '
search for files in the current folder which start with "myfile" ( case insensitive search )
find . -iname 'MyFile*'
search for the file in the entire file system which has the words "filename" in its name
find / -name ”*filename*”
Search for files in your home directory which have been modified in the last twenty-four hours
find $HOME -mtime 0
Search for files in your home directory which have been modified in the last twenty-four hours.
find $HOME -mtime 0
search for the file job.hostory in the folder "/data/Spoolln"
find /data/SpoolIn -name job.history
search for files named "WSFY321.c" in a case-insensitive manner
find . -iname "WSFY321.c"
Search for file names with "bad" characters in the current directory and delete the files.
find . -name '*[+{;"\\=?~()<>&*|$ ]*' -maxdepth 0 -exec rm -f '{}' \;
Search for files only that end with .php and look for the string $test inside those files
find . -name \*.php -type f -exec grep -Hn '$test' {} \+
Search for files only that end with .php and look for the string $test inside those files
find . -name \*.php -type f -exec grep -Hn '$test' {} \;
Search for files only that end with .php and look for the string $test inside those files
find . -name \*.php -type f -print0 | xargs -0 -n1 grep -Hn '$test'
Search for files only that end with .php and look for the string $test inside those files
find . -name \*.php -type f -print0 | xargs -0 grep -Hn '$test'
search for the file picasso in the folder /home/calvin/ (case insensitive search)
find /home/calvin/ -iname “picasso”
Search for files specifying the maximum depth of the search
find -maxdepth num -name query
Search for files specifying the minimum depth of the search
find -mindepth num -name query
search for files starting with memo and which belong to the user ann in the folder /work
find /work -name 'memo*' -user ann -print
search for the file test in the current folder
find . -name test
search for the file test.txt in the folders /home and /opt
find /home /opt -name test.txt
search for the file test2 in the current folder
find -name test2
Search for files that are at least 1.1GB
find / -size +1.1G
Search for files that are at least 100MB
find / -size +100M
Search for the files that are owned by user rooter or by user www-data
find -user root -o -user www-data
Search for files that were accessed less than 5 days ago.
find -atime -5
search for files which are writable by both their owner and their group
find . -perm -220
search for files which are writable by both their owner and their group
find . -perm -g+w,u+w
Search for files which are writable by somebody
find . -perm /222
search for the files which contain the word start in their name excluding search in ./proc, ./sys, ./run folders
find . -path ./proc -prune -or -path ./sys -prune -or -path ./run -prune -or -iname '*start*' -print
Search for files which have read and write permission for their owner and group, and which other users can read, without regard to the presence of any extra permission bits
find . -perm -664
Search for files whose name is "filename" and whose permissions are 777
find / -perm 777 -iname "filename"
Search for files with "demo" in their names and "sitesearch" in their path names
find . -iname '*demo*' | grep -i sitesearch
Search for files with "sitesearch" in their names and "demo" in their path names
find . -iname '*sitesearch*' | grep demo
search for the files with the name "temp" and which have not been accessed in the last 7*24 hours in the /usr folder
find /usr -name temp -atime +7 -print
search for files with the name "temp" in the /usr folder
find /usr -name temp -print
Search for filenames matching "android" in the current directory and number the output
ls | grep android | nl
Search for first match of the case insensitive regex 'oyss' in all *.txt files under current directory and print the file paths along with the matches
find . -name '*.txt'|xargs grep -m1 -ri 'oyss'
Search for first match of the case insensitive regex 're' in all *.coffee files under current directory
find . -name \*.coffee -exec grep -m1 -i 're' {} \;
Search for first match of the case insensitive regex 're' in all *.coffee files under current directory and print the file paths along with the matches
find . -print0 -name '*.coffee'|xargs -0 grep -m1 -ri 're'
search for the folder .dummy and remove it from the folder "Test folder"
find "Test Folder" -type d -name '.dummy' -delete
search for the folder .dummy and remove it from the folder "Test folder"
find "Test Folder" -type d -name .dummy -exec rm -rf \"{}\" \;
search for the folder .dummy in the entire directory structure of "test folder" and remove it.
find -depth "Test Folder" -type d -name .dummy -exec rm -rf \{\} \;
Search for hidden files non-recursively
find . -name '.?*' -prune
search for the host "slc02oxm.us.oracle.com" in all the xml files in the current folder and display the files which has the matched content
find -name “*.xml” -exec grep -l “slc02oxm.us.oracle.com” {} \;
search for the ip "192.168.1.5" in all the files in /etc folder
find /etc/ -iname "*" | xargs grep '192.168.1.5'
Search for line 111 in file "active_record.rb" with 2 lines of context
nl -ba -nln active_record.rb | grep -C 2 '^111 '
Search for line number 111 in file "active_record.rb"
nl -ba -nln active_record.rb | grep '^111 '
Search for lines that have zero or more whitespace characters before "http://" and number the uniquely sorted output
grep '^[[:space:]]*http://' | sort -u | nl
search for MP3 files in the current folder and subfolders except in dir1 subfolder.
find ! -path "dir1" -iname "*.mp3"
search for MP3 files in the current folder and subfolders exclude dir1 AND dir2
find ! -path "dir1" ! -path "dir2" -iname "*.mp3"
search for mp3 files in the folder /mp3collection which are smaller than 5MB
find /mp3collection -name '*.mp3' -size -5000k
search for multiple files in the current folder
find . -name photoA.jpg photoB.jpg photoC.jpg
Search for non-empty files
find . ! -size 0k
Search for occurrences of string "main(" in the .c files from the current directory tree
find . -name "*.c" -print | xargs grep "main("
Search for occurrences of string "main(" in the .c files from the current directory tree
find . -type f -name "*.c" -print -exec grep -s "main(" {} \;