nl
stringlengths
13
387
bash
stringlengths
1
532
Find every file/directory under the directory /home owned by the user joe
find /home -user joe
Find every file under the directory /home owned by the user joe.
find /home -user joe
Find every file under the directory /usr ending in ".stat".
find /usr -name *stat
Find every file under the directory /var/spool that was modified more than 60 days ago.
find /var/spool -mtime +60
Finds every folder with file 'header.php' within, and copies file 'topscripts.php' to every one of them.
find -type f -name 'header.php' | xargs -n 1 dirname | xargs -n 1 cp -f topscripts.php
Find every vim undo file under current directory
find -type f -iname '*.un~'
Find executable files
find . -perm -100 -print
find the file "MyCProgram.c" in the current folder
find -iname "MyCProgram.c"
find the file "dateiname" in the current folder ( case insensitive search)
find -iname "Dateiname"
find the file "dateiname" in the entire file system ( case insensitive search)
find / -iname "Dateiname"
find the file "filename.txt" in the entire file system
find / -name filename.txt -print
find the file "foo.txt" in the current folder and assign the output to a variable
OUTPUT=`find . -name foo.txt`
find the file "httpd.log" in the entire file system
find / -type f -name httpd.log
find the file "httpd.log" in the folder /home/web-server/
find /home/web-server/ -type f -name httpd.log
find the file "httpd.log" in the folder /home/web-server/ ( case insensitive search )
find /home/web-server/ -type f -iname httpd.log
Find file `Chapter1' on the system
find / -name Chapter1 -type f -print
Finds file 'Subscription.java' and changes to containing folder.
cd $(find . -name Subscription.java | xargs dirname)
Finds file 'Subscription.java' and changes to containing folder.
cd `find . -name Subscription.java | xargs dirname`
Find file `hosts'
find /etc -name hosts
Find files accessed at 23:59
find . -atime -1 -print
Find files/directories in entire file system that have been modified in the last minute
find / -mmin -1
Find files/directories in entire file system that had their meta information changed more than 3 days ago
find / -ctime +3
Find files/directories in entire file system that were accessed in less than a day ago
find / -atime -1
Find files/directories in entire file system that were modified a day ago
find / -mtime 1
Find files and directories modified in last 24 hours
find . -mtime 1
Find files and directories modified within the last 7 days
find . -mtime -7
Find files/directories modified within the last day under /etc
find /etc -type f -ctime -1
Find files/directories modified within the last hour under current directory
find . -mtime -1
Find files/directories named 'TEST_3' under current directory tree
find -name TEST_3
Find files/directories named 'articles.jpg' under current directory tree and change their permission to 644
find . -name "articles.jpg" -exec chmod 644 {} \;
Find files/directories named 'document' in 'ext2' partitions in entire filesystem
find / -fstype ext2 -name document -print
Find files/directories named 'document' in the entire filesystem and in the directory tree '/usr' even if it's in a different partition without traversing to other devices/partitions
find / /usr -xdev -name document -print
Find files/directories named 'file.txt' in the path '/usr/lib/important/'
find / -path /usr/lib/important/*/file.txt
Find files/directories named 'file.txt' that belong to user 'tutonics' in the entire filesystem
find / -user tutonics -name "file.txt"
Find files/directories named 'foo' in the current partition of the root filesystem
find -x / -name foo
Find files/directories named 'foo.bar' in the root filesystem partition
find / -name foo.bar -print -xdev
Find files/directories named 'foo.bar' under './dir1' and './dir2' directory tree
find ./dir1 ./dir2 -name foo.bar -print
Find files/directories named 'sar' under '/usr', '/bin', '/sbin' and '/opt' directory tree
find /usr /bin /sbin /opt -name sar
Find files/directories named blah (case insensitive) under current directory
find ./ -iname blah
Find files/directories named blah under current directory
find ./ -name blah
Find files/directories named<filetype> under current directory which were accessed less than 5 days ago
find -name "<filetype>" -atime -5
Find files and directories newer than CompareFile under current directory
find . -newer CompareFile -print
Find files/directories not changed in two weeks under /dev/shm
find /dev/shm /tmp -type f -ctime +14
Find files and directories owned by xuser1 and change their ownership to user2
find . -user xuser1 -exec chown -R user2 {} \;
Find files and directories that are at least seven levels of nesting in the directory /usr/src
find /usr/src -name CVS -prune -o -mindepth 7 -print
Find files/directories that are bigger than 10000 KB in size uder '/usr/local' directory tree
find /usr/local -size +10000k
Find files/directories that are newer than 'foo.txt' under current directory tree
find -newer foo.txt
Find files/directories that belong to user 'ian' under '/tmp' directory tree
find /tmp -user ian
Find files/directories that isn't owned by the user 'apache' under /var/www
find /var/www ! -user apache -print0 | xargs -0
Find files/directories that have no owner or group under /path
find /path -nouser -or -nogroup
Find files/directories that have not been modified in the last one day in directories or files taken from the glob pattern '/tmp/test/*'
find /tmp/test/* -daystart -mtime +1
Find files/directories that does not have write permssion for group
find /path ! -perm /020
Find files/directories that does not have write permssion for group
find /path ! -perm /g+w
Find files/directories that does not have write permssion for group and others
find /path ! -perm /022
Find files/directories under '/dir' directory tree that are newer than 'yesterday.ref' file and older than 'today.ref' file by modification time
find /dir -newer yesterday.ref -a \! -newer today.ref -print
Find files/directories under '/usr' directory tree that are newer than /tmp/stamp$$ by modification time
find /usr -newer /tmp/stamp$$
Find files/directories under /tmp smaller than 100 bytes
find /tmp -size -100c
Find files/directories under current directory and print them
find . -print0 | xargs -0 echo
Find files/directories under current directory and print them as null terminated strings.
find -print0
Find files/directories under current directory excluding the path ./src/emacs
find . -path ./src/emacs -prune -o -print
Find files/directories under current directory matching the posix-egrep type regex ".+\.(c|cpp|h)$" in their names
find . -regextype posix-egrep -regex ".+\.(c|cpp|h)$"
Find files/directories under current directory that are modified exactly one hour ago
find . -mtime 1
Find files/directories under current directory that matches './projects/insanewebproject' in their paths
find -ipath './projects/insanewebproject'
Find files/directories under current directory that matches './projects/insanewebproject' in their paths and show the first one
find -ipath './projects/insanewebproject'| head -n1
Find files/directories under current directory that matches 'projects/insanewebproject' in their paths
find -ipath 'projects/insanewebproject'
Find files/directories under current directory that matches the regex /path/to/something[^/]*$ in their paths
find . | grep -qi /path/to/something[^/]*$
Find files/directories under current directory without descending into it
find -maxdepth 0
Find files/directories under current directory without descending into it
find -prune
Find files and directories whose owner is daniel
find . -user daniel
Find files/directories with exactly read,write and execute permission for all (owner, group and others) under /path
find /path -perm 777
Find files/directories with exactly read,write and execute permission for all (owner, group and others) under /path
find /path -perm ugo+rwx
Find files and directories with group id 1003
find . -gid 1003
Find files/directories with inode number '212042' under '/var' directory tree without traversing other devices/partitions
find -x /var -inum 212042
Find files and directories with the name RAID but don't traverse a particular directory
find . -name RAID -prune -o -print
Find files/directories writable by group or others under the /path directory
find /path -perm /g+w,o+w
Find files associated with an inode
find . -inum 968746 -exec ls -l {} \;
Find files associated with an inode
find . -inum 968746 -print
Find files belonging to the given owner
find /path/to/search -user owner
Find files bigger than 20 megabytes in the home directory tree
find ~ -size +20M
Find files by type
find -type type_descriptor
Find files changed in the last 1 day
find . -mtime -1 -type f
find files changed in the last 1 day
find . -mtime -1 -type f
Find files containing `blah' in their names modified less than 2 days ago, case insensitive
find . -iname '*blah*' -mtime -2
Find files containing string "#!/bin/ksh" and append their names and matching strings to /tmp/allfiles
find . -type f -execdir /usr/bin/grep -iH '#!/bin/ksh' {} \; | tee /tmp/allfiles
Find files containing string "#!/bin/ksh" and append their names and matching strings to /tmp/allfiles
find . -type f -print | xargs /usr/bin/grep -il 'bin/ksh' | tee /tmp/allfiles
Find files ending in "f"
find . -path '*f'
find files ending with .jpg
find . -name '*.jpg' -print ./bar/foo.jpg
Find files in the "dir" directory tree whose names are 33 characters in length
find dir -name '?????????????????????????????????'
Find files in $DIR_TO_CLEAN that are older than $DAYS_TO_SAVE days and print them with null character appended to their paths
find "${DIR_TO_CLEAN?}" -type f -mtime +${DAYS_TO_SAVE?} -print0
find files in $HOME ending in "txt" or "html" and case insensitive search for the word "vpn"
find $HOME \( -name \*txt -o -name \*html \) -print0 | xargs -0 grep -li vpn
Finds files in 'directory' folder with the same name and location but different content than files in 'directory.original' folder and prints location of such files.
diff -qr directory directory.original | cut -d' ' -f2 | xargs dirname | uniq
Finds files in 'directory' folder with the same name and location but different content than files in 'directory.original' folder and saves location of such files to 'directories' variable.
directories=$(diff -qr directory directory.original | cut -d' ' -f2 | xargs dirname | uniq)
find files in /dir/path/look/up directory that names are dir-name-here
find /dir/path/look/up -name "dir-name-here"
find files in /dir/path/look/up directory that names are dir-name-here
find /dir/path/look/up -name "dir-name-here" -print
find files in /tmp directory that named are core and deletes them, single or double quotes, spaces or newlines are correctly handled
find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
Find files in the /travelphotos that are greater than 200k in size but do not have "2015" anywhere in the file name
find /travelphotos -type f -size +200k -not -iname "*2015*"
find files in /usr directory which are modified after February 1 of the current year
find /usr -newermt "Feb 1"
find files in the /usr/src directory with pattern` *.c that larger than 100 Kilobytes
find /usr/src -name '*.c' -size +100k -print
Find files in the /var/log folder which were modified an hour or more ago
find /var/log/ -mmin +60
Find files in the /var/log folder which were modified between 60 minutes and 10 minutes ago
find /var/log/ -mmin -60 -mmin +10