nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
list directories owned by group ID 100 in the file system
find / -type d -gid 100
search for soft links in current folder and display those links which are not pointed to files in current folder
find . -type l -exec readlink -f '{}' \; | grep -v "^`readlink -f ${PWD}`"
Verbosely compresses all files on third and fourth depth level keeping original files in place.
bzip2 -kv */*/*
Locate all files in the current directory and below that do not have "testfileasdf" in their names
find -not -name "*testfileasdf*"
Search directory /home/ABCD recursively, starting from one level below, for regular files
find /home/ABCD/ -mindepth 1 -type f -print
This find command ignore the case when searching for file name , to ignore the case in this example all .py & .PY file will search
find . -type f -iname "*.py"
Find all files/directories under '/etc' directory tree that are greater than 5MB and print their sizes and names
find /etc -size +5M -exec ls -sh {} +
Download "http://archive.ubuntu.com/ubuntu/pool/universe/s/splint/splint_3.1.2.dfsg1-2.diff.gz", unzip it, and view the output in "less"
curl -s 'http://archive.ubuntu.com/ubuntu/pool/universe/s/splint/splint_3.1.2.dfsg1-2.diff.gz' | gunzip -dc | less
Print the path names of all regular .rb files prefixing them with string "Hello, "
find . -name "*.rb" -type f | xargs -I {} echo Hello, {} !
For each line in 'file', print "result = " followed by the line backwards.
rev file | awk '{print "result =",$0}'
find all the files in the folder /home which are bigger than 10MB and smaller than 50 MB
find /home -size +10M -size -50M
Read a line from standard input into variable "response" ignoring backslash escapes and using the prompt "${1:-Are you sure? [y/N]} "
read -r -p "${1:-Are you sure? [y/N]} " response
find the regular/normal file "myfile" in the folder /root
find /root/ -name myfile -type f
search in current directory downwards all files whose size is less then 10 bytes
find . -size -10c -print
Display bash function definition of "foobar"
set | grep -A999 '^foobar ' | grep -m1 -B999 '^}'
search for the word foo in all the js files in the current folder
grep -iH foo `find . -name "*.js"`
Find all files in the current directory tree whose size is greater than 1MB, and move them to the "files" folder
find . -size +1M -print0 | xargs -0 -I '{}' mv '{}' files
List level 2 subdirectories of the current directory
find . -mindepth 2 -maxdepth 2 -type d -ls
Find all files accessed on the 29th of September, 2008, starting from the current directory
find . -type f -newerat 2008-09-29 ! -newerat 2008-09-30
Print list of files that are only in directory /dir1 and not their sub directories and only their file names.
diff -q /dir1 /dir2 | grep /dir1 | grep -E "^Only in*" | sed -n 's/[^:]*: //p'
Remove files under current directory that contains white space in their name
find . -name "* *" -exec rm -f {} \;
display all the files in the current folder excluding the perl files
find . -not -name "*.pl"
copy the file header.shtml to each directory under dir1, dir2, dir3, or dir4
find dir1 dir2 dir3 dir4 -type d -exec cp header.shtml {} \;
Find all files under /path/to/base/dir and change their permission to 644
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644
find all the directories in the current folder which begin with the words "kt" and end with a digit
find . -regex './kt[0-9] '
Search the current directory tree for PHP files changed less than 14 days ago
find . -name *.php -ctime -14
Display information on CPU usage.
top -bn1 | sed -n '/Cpu/p'
find all the regular/normal files in the current directory which do not have the extension comment and and redirect the output to /tmp/list
find . -type f \! -name "*.Z" \! -name ".comment" -print | tee -a /tmp/list
Find all files in the `work' directory tree, pass them to grep and search for "profit"
find ./work -print | xargs grep "profit"
Change directory to the "lib" directory located two parent directories above the path to command "perl"
cd $(dirname $(dirname $))/lib
Find all files under the current directory whose filenames are not "file.txt", ignoring the case
find . -maxdepth 1 -not -iname file.txt
Find files associated with an inode
find . -inum 968746 -exec ls -l {} \;
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' {} \;
Print file type of the executable file of command "python"
file `which python`
Show file type information for files in /usr/bin
find /usr/bin | xargs file
Find and delete all hard links in the /home directory to file1
find /home -xdev -samefile file1 -exec rm {} +
Sort all files/directories under current directory according to modification time and print only the recent 7 of them
find -mindepth 1 -printf "%T@ %P\n" | sort -n -r | cut -d' ' -f 2- | tail -n +7
Scan every file in /etc for IPV4 addresses while trying to elminate false positives.
find /etc -type f -exec cat '{}' \; | tr -c '.[:digit:]' '\n' | grep '^[^.][^.]*\.[^.][^.]*\.[^.][^.]*\.[^.][^.]*$'
Add a date time stamp to every line of output in "ping google.com"
ping google.com | xargs -L 1 -I '{}' date '+%c: {}'
find all teh script files in a directory
find /home/john -name "*.sh" -type f -print
Find all regular files that start with stat
find . -type f –iname stat*
Make directory "/cpuset"
mkdir /cpuset
Find all files/directories that contain 'target' in their names under current directory no-recursively
find -maxdepth 1 -iname "*target*"
Search the regular files from directory tree 'directory_name' for "word" and print the names of the matched files
find directory_name -type f -print0 | xargs -0 grep -li word
display all text files in the folder /tmp/1
find "/tmp/1" -iname "*.txt"
find all files which name contain 'foo' and path is not dir1 or dir2
find ! -path "dir1" ! -path "dir2" -name "*foo*"
Create a compressed archive from "www" and split the contents into files of at most 1073741824 bytes and use prefix "www-backup.tar."
tar czf - www|split -b 1073741824 - www-backup.tar.
Remove all CVS directories from the current directory tree
find . -name 'CVS' -type d -exec rm -rf {} \;
delete all the backup files in current directory
find . -name "*.bak" -delete
Search folder /home/ABCD/ recursively for regular files
find /home/ABCD/ -type f -print
run "tar -xzvf ..." as user $username
su $username -c tar xzvf ..
find all the php files in the current folder
find . -name \*.php
Print summary of new/missing files, and which files differ between folder1 and folder2, excluding those matching pattern "node_modules".
diff -rqyl folder1 folder2 --exclude=node_modules
Search for "largecalculation" in all processes owned by the current user
ps -u `whoami` | grep largecalculation
Find all the files which were accessed 50 days ago
find / -atime 50
Rename all files matching "access.log.<number>.gz" incrementing <number>.
find -name 'access.log.*.gz' | sort -Vr | rename 's//$1+1/ge'
Delete all the files found in the current directory tree whose names begin with "heapdump"
find . -name heapdump*|xargs rm
Print the path of all the network mounts
mount | sed -n -e "s/\/\/mynetaddr on \.*$/\1/p"
find all jpg,png,jpeg,pdf,tif,tiff,bmp and other image formats using regular expressions excluding those ending with "_ocr.pdf"
find /somepath -type f -iregex ".*\." ! -name "*_ocr.pdf" -print0
SSH into user@server and run command ${SSH_COMMAND}
ssh user@server "${SSH_COMMAND}"
Prints shell option 'globstar' with indication of its status.
shopt -p globstar
List files larger than 10MB in the /var directory recursively
find /var/ -size +10M -exec ls -lh {} \;
display the list of all the text files present in the current directory excluding the search in certain paths.
find . -type f -name "*.txt" ! -path "./Movies/*" ! -path "./Downloads/*" ! -path "./Music/*" -ls
display all files ending with ".ext" in current folder and append the file contents of list.txt and sort them based on name and display only uniq items
find . -name \*.ext | cat - list.txt | sort | uniq -u
Prints current directory name
pwd | grep -o "\w*-*$"
Find all regular files under current directory
find . -depth -type f -print
Disable X11 forwarding and execute "cd yourRemoteDir; ./yourRemoteScript.sh </dev/null >/dev/null 2>&1" in the background on "remoteServer"
ssh -x remoteServer "cd yourRemoteDir; ./yourRemoteScript.sh </dev/null >/dev/null 2>&1 & "
Find target.txt files in the /base/path/of/proj/d‌​ata directory tree and pass them as arguments to simpleGrepScript.sh, saving the output as overallenergy.out
find /base/path/of/proj/d‌​ata -name target.txt | xargs simpleGrepScript.sh > overallenergy.out
Recursively set all permissions under "/folder" to 755
chmod 755 /folder -R
Search the current directory recursively for regular files with the read permission set for everybody
find -type f ! -perm -444
Display all the files/directories under '/home/bozo/projects' directory tree that have been modified within the last day
find /home/bozo/projects -mtime -1
Make directories and parents as needed for each file path in "a.txt" excluding the basename for each path
cat a.txt | grep / | sed 's|/[^/]*$||' | sort -u | xargs -d $'\n' mkdir -p
Get A record for domain $domain
dig $domain
find all the javascript files in current folder using regular expressions
find . -regex '.+\.js'
Find all regular files under current directory tree whose names end with 'cache' or 'xml' or 'html'
find . -type f \
Find all executable upvoter-* files (following symlinks) under maximum 1 level down the current directory
find -L -maxdepth 1 -name 'upvoter-*' -type f -perm /111
Replace "string1" with "string2" in all regular files in the current directory tree
find ./ -type f -exec sed -i 's/string1/string2/g' {} \;
Reformat date "Sat Aug 09 13:37:14 2014 +1100" according to format string "%a %b %d %H:%M:%S %Y %z"
date -j -f "%a %b %d %H:%M:%S %Y %z" "Sat Aug 09 13:37:14 2014 +1100"
Print the full path of executable "lshw"
which lshw
Find all files/directories named 'javac' under current directory
find . -name 'javac'
Recursively removes $TMPDIR folder, prompting user on each deletion.
rm -r $TMPDIR
delete all the mp3 files in the home folder
find /home/ -exec grep -l “mp3” {} \; | xargs rm
Represent time string $MOD_DATE as seconds since epoch and save to variable 'MOD_DATE1'
MOD_DATE1=$
Add "Line of text here" on top of each *.py files under current directory
find . -name \*.py -print0 | xargs -0 sed -i '1a Line of text here'
delete all the files which start with "Tes" in the current folder
find . -type f -name "Tes*" -exec rm {} \;
Find all *.txt files that reside under and below /home/wsuNID/
find /home/wsuNID/ -name "*.txt"
find all the regular/normal files in the current folder and rename them to html files
find main-directory -type f -exec mv -v '{}' '{}'.html \;
find all the files in the entire file system starting with the word top
find / -name 'top?????*'
search for swap files in temp folder and remove them
find /tmp -name '*.swp' -exec rm {} \;
display all the files ending with ".user" in /var/adm/logs/morelogs/ and excluding all regular files
find /var/adm/logs/morelogs/* -type f -prune -name "*.user" -print
display all regular/normal files in a directory
find $directory -type f
Decompress 'file.gz'
gzip -d file.gz
Print the full path directory name of each "file.ext" found under the current directory
find . -name "file.ext" -execdir pwd ';'
Display the host's ECDSA fingerprint using the sha256 hasing algorithm.
ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key.pub
Move all *.data files/directories in $S directory to $S/data/ directory
find "${S}" -name '*.data' -exec mv '{}' "${S}/data/" \;
find all the files with the name september
find -iname september
Find all *.txt files under current directory and print their timestamps and paths
find . -name "*.txt" -printf "%T+ %p\n"
List the last modified file under "$DIR"
find $DIR -type f -printf "%T@ %p\n" | sort -n | cut -d' ' -f 2 | tail -n 1
create a tar ball of all pdf files in current folder
find . -name *.pdf | xargs tar czvf /root/Desktop/evidence/pdf.tar
Find all the files whose permissions are 777
find . -type f -perm 0777 -print