nl
stringlengths
13
387
bash
stringlengths
1
532
Find files that were modified less than 7 days ago and archive them
find . -type f -mtime -7 | xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find files that were modified more than 7 days ago and archive them
find . -type f -mtime +7 | xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find files that were modified more than 7 days ago but less than 14 days ago and archive them
find . -type f -mtime +7 -mtime -14 | xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find files that were modified second last week and archive them
find . -type f -mtime +7 -mtime -14 | xargs tar -cvf `date ‘+%d%m%Y’_archive.tar`
Find files under '/travelphotos' directory tree which are bigger than 200KB and do not have 2015 in their names
find /travelphotos -type f -size +200k -not -iname "*2015*"
Find files under /etc/apache-perl that are modified more recently than /etc/apache-perl/httpd.conf
find /etc/apache-perl -newer /etc/apache-perl/httpd.conf
Find files under /some/path that are not executable
find /some/path -type f ! -perm -111 -ls
Find files under /some/path that are not executable by the owner
find /some/path -type f ! -perm -100 -ls
Find files under /tmp that are larger than 10KB and smaller than 20KB
find /tmp -size +10k -size -20k
Find files under /usr that are the same age or older than file `FirstFile'
find /usr ! -newer /FirstFile -print
Find files under [directory] that match 'pattern_to_INCLUDE' in their names without descending into directories that match 'pattern_to_exclude' and 'another_pattern_to_exclude', then search for 'pattern' in those files
find [directory] -name "pattern_to_exclude" -prune -o -name "another_pattern_to_exclude" -prune -o -name "pattern_to_INCLUDE" -print0 | xargs -0 -I FILENAME grep -IR "pattern" FILENAME
find files under the current directory called "foo" or "bar"
find . \( -name "foo" -o -name "bar" \)
find files under the current directory containing a space in the filename and delete them
find . -name "* *" -exec rm -f {} \;
find files under the current directory ending in "txt" and list them, or ending in "html" but do nothing.
find . -name '*.txt' -print -o -name '*.html'
Find files under current directory that are newer than $date_time in regards of modification time
find . -type f -newermt "$date_time"
Find files under current directory that are not newer than $date_time in regards of modification time
find . -type f -not -newermt "$date_time"
Find files under current directory that contains the string '/bin/ksh'
find . -type f -exec grep -iH '/bin/ksh' {} \;
Find files under current directory that contains the string '/bin/ksh'
find . -type f -print | xargs grep -il 'bin/ksh'
Find files under current directory without descending into other file systems and append a null character at the end of each paths
find -x . -type f -print0
Find files using file-name
find -iname "MyCProgram.c"
Find files which are more than 2 days old under ${userdir}/${i}/incoming directory
find ${userdir}/${i}/incoming -mtime +2 -type f -ls
Find files which are more than 2 days old under ${userdir}/${i}/incoming directory and remove them
find ${userdir}/${i}/incoming -mtime +2 -type f -exec rm {} \;
find file which case-insensitive name is foo in current directory.
find . -iname foo
find file which case-insensitive name is too in currect directory
find . -iname foo
find files which full path name is /tmp/foo/bar under /tmp/foo directory and print
find /tmp/foo -path /tmp/foo/bar -print
find files which full path name is /tmpfoo/bar under /tmp/foo directory and print
find /tmp/foo -path /tmp/foo/bar -print /tmp/foo/bar
find files which full path name is /tmpfoo/bar under foo directory and print
find foo -path /tmp/foo/bar -print
find files which full path name is foo/bar under foo directory and print
find foo -path /tmp/foo/bar -print
find files which full path name is foo/bar under foo directory and print
find foo -path foo/bar -print
find files which full path name like '*/*config' at current directory and print
find . -path '*/*config'
find files which full path name like '*f' at current directory and print
find . -path '*f'
find files which modification time is 7 days ago
find . -mtime -7
find files which modification time is one day ago
find . -mtime 1
find files which do not have all permissions to all the users in the current directory
find . -type f ! -perm 777 | head
Find files which were changed in the past 1 hour
find . -cmin -60
Find files whose content was modified at least 1 minute ago
find ./ -mmin +1
Find files whose data was modified within the given days of the month
find ./ -daystart -mtime -10 -and -mtime +1
Find files whose name starts with "MyFile", ignoring the case
find . -iname 'MyFile*'
Find files whose pathnames end in "config"
find . -path '*/*config'
Find files with 002 permission in entire file system
find / -type f -perm -002
Find files with 002 permission in entire file system and print them with the string 'has world write permissions' appended after every path
find / -type f -perm -002 -printf '%p has world write permissions\n'
Find files with 002 permission in entire file system and print them with the string 'has world write permissions' printed at last
echo $(find / -type f -perm -002) has world write permissions
Find files with 777 permissions and change them to 755
find / -type f -perm 0777 -print -exec chmod 755 {} \;
Find files with a question mark in their names
find . -name \*\\?\*
Find files with the extension .conf in the /etc directory
find /etc -name '*.conf'
find files with the extension .conf in the /etc directory
find /etc -name '*.conf'
Find files with extension .conf in the /etc directory tree
find /etc -name "*.conf"
Find files with group write permission and remove the permission
find . -perm -20 -exec chmod g-w {} ;
Find files with group write permission and remove the permission
find . -perm -20 -print | xargs chmod g-w
Find the file with inode number 211028 in the current dirrectory tree and move it to newname.dir
find . -inum 211028 -exec mv {} newname.dir \;
find the file with the name "esxcfg-firewall" in the current folder
find -print | grep esxcfg-firewall
Find files with name `aaa.txt' under the current directory
find . -name aaa.txt
find files with pattern` '*.h' and print comparison between file and /tmp/master directory
find . -name '*.h' -execdir diff -u '{}' /tmp/master ';'
Find files with SGID (2000) and SUID(4000) permssions set in the file system
find / \( -perm -2000 -o -perm -4000 \) -ls
Find files with size more than 200557600B and which are more than 2 days old under ${userdir}/${i}/incoming directory
find ${userdir}/${i}/incoming -mtime +2 -type f -size +200557600c -ls
Find files with size more than 200557600B and which are more than 2 days old under ${userdir}/${i}/incoming directory and remove them
find ${userdir}/${i}/incoming -mtime +2 -type f -size +200557600c -exec rm {} \;
Find file1 in the level 1 directories and above
find -maxdepth 2 -name file1
Find find symlinks pointing to /mnt/oldname* in the entire file system
find / -type l -lname '/mnt/oldname*'
Find the first file/directory named 'something' under current directory and quit
find . -name something -print -quit
Find the first file/directory under $DIR which matches the $TMP_DIR in its path
/usr/bin/find $DIR -maxdepth 1 -ipath $TMP_DIR -print -quit
Finds the folder where temporary files would be written to.
dirname $(mktemp -u -t tmp.XXXXXXXXXX)
find foo, Foo, FOo, FOO, etc., but only dirs
find . -iname foo -type d
find foo, Foo, FOo, FOO, etc., but only files
find . -iname foo -type f
find for a filename with multiple patterns in the current folder
find . -name "photo*.jpg"
find for a word in all the regular files in the current directory
find . -type f -exec grep -li '/bin/ksh' {} \;
find for a word in all the regular files in the current directory
find . -type f -print | xargs grep -li 'bin/ksh'
find for lighttpd in /var
find /var -name lighttpd
find for the word "dba_2pc_pending" in all the files of current fodler having the word "sql" in their name
find . -print|grep sql|xargs grep -i dba_2pc_pending
find for xml files in current folder using regular expressions
find ./ -regex "cmn-.*[\x4e00-\x9fa5]*\.xml"
Find hard links to the same file lpi104-6/file1 in the directory tree lpi104-6
find lpi104-6 -samefile lpi104-6/file1
find httpd.conf file in /etc directory
find /etc -name "httpd.conf"
Finds if environment variable like 'DUALCASE' exists in environment.
env | grep DUALCASE
find in $HOME files ending in "txt" and do nothing with them, or files ending in "html" and list them null separated.
find $HOME -name \*txt -o -name \*html -print0
Find in the current direcoty whose suffix is .tmp , find will not serach recursively limit of find is 2 subdirectory .
find . -maxdepth 2 -name '*.tmp'
find in the entire file system for the file mysql
sudo find / -name mysql -print
find in the entire file system for the files which have sticky bit.
find / -perm 0551
find js file which name is not 'glob-for-excluded-dir' under current directory.
find . -name '*.js' -\! -name 'glob-for-excluded-dir' -prune
Find the largest 10 files (regular files) under current directory
find . -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
Find the largest files in a particular location
find /home/tecmint/Downloads/ -type f -exec du -Sh {} + | sort -rh | head -n 5
Find the largest files in a particular location
find /home/tecmint/Downloads/ -type f -printf "%s %p\n" | sort -rn | head -n 5
Find largest file in linux with find command
find . -type f -printf "%s\t%p\n" | sort -n | tail -1
Find links to any file that happens to be named `foo.txt'
find . -lname \*foo.txt
Find links to any file that happens to be named `foo.txt'
find / -lname foo.txt
Find links to file path/to/foo.txt
find -L / -samefile path/to/foo.txt
find list of all files with file permission , link , owner , group , reation time , size , file name
find . -exec ls -ld {} \;
finda ll the files in the current folder that are modified today.
find ~ -type f -mtime 0 -ls
Find how many directories are in a path (counts current directory)
find . -type d -exec basename {} \; | wc -l
Find how many files are in a path
find . -type f -exec basename {} \; | wc -l
Finds matched text in defined path recursively, but not follows symlinks.
grep -r "string to be searched" /path/to/dir
find the md5 sum of all the regular files in multiple folders and display them in sorted order
find teste1 teste2 -type f -exec md5 -r {} \; | sort
find md5sum of 'string to be hashed'
echo 'string to be hashed' | md5
find md5sum of 'string to be hashed'
md5 -s 'string to be hashed'
find md5sum of 401
yosemite$ echo -n 401 | md5
find md5sum of an empty string
echo -n '' | md5
find md5sum of content from "www.google.com"
curl -s www.google.com | md5
find md5sum of string 'hi'
echo -n hi | md5
Finds more than 5 days old files in two directories and compresses them.
find /home/folder1 /home/folder2 -type f -mtime +5 -exec compress {} \;
Find the most recently changed files in a subtree
find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort
find the most recently changed files under current directory
find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort
Find movies over a gigabyte in size
find ~/Movies/ -size +1024M