nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
Search for the pattern '^use strict' in all *.pl files under current directory
find . -name '*.pl' | xargs grep -L '^use strict'
Find all *.ext files/directories under current directory and print their path and parent directory path
find /path -type f -name "*.ext" -printf "%p:%h\n"
Search the current directory recursively for files last modified within the past 24 hours ignoring .swp files and "en" and "es" directories
find . \( -name en -o -name es \) -prune , -mtime 0 ! -name "*.swp"
Delete all empty files/directories under test directory
find test -depth -empty -delete
Print lines in the sorted contents of "second.txt" that are not in the sorted contents of "first.txt"
comm -13 < <
Print unique lines of sorted file "f1" compared to sorted file "f2"
comm -2 -3 f1 f2
find in the file system for the directories with the name "httpdocs"
find / -type d -name 'httpdocs'
find all the png files in current folder which are present in the pattern list file "search.txt" and copy them to another directory
find . -name '*.png' | grep -f < | xargs -i{} cp {} /path/to/dir
Search the system for files named "findcommandexamples.txt", ignoring the case
find / -iname findcommandexamples.txt
Find all files/directories that are owned by user 'takuya' under current directory tree
find -user takuya
List environment variable values whose name matches '^\w*X\w*'
set | grep -P '^\w*X\w*' | grep -oP '.*'
display all the log files in the folder /var/log, print0 is used to handle files with only spaces in their names or which have newlines in their names
find /var/log -name "*.log" -print0
save the list of all the trace files from the folder $DBA/$ORACLE_SID/bdump/ which have been modified in the last 24 hours
find $DBA/$ORACLE_SID/bdump/*.trc -mtime -1 -print >> /tmp/trace_list.lst
Search the current directory tree for a regular file named "file_name"
find . -type f -name file_name
Move all files that contain "Subject: \[SPAM\]" to "DIR"
grep -L -Z -r 'Subject: \[SPAM\]' . | xargs -0 -I{} mv {} DIR
Show the last 10 .conf files found by `find' in the /etc directory and 1 level below
find /etc -maxdepth 2 -name "*.conf" | tail
Print content of all files ending with '*.foo' under the current directory
cat $
Executes 'cd /' in a subshell created by a pipeline of built-in function 'true'.
true | cd /
Remove all *.txt files, except robots.txt, under the given directory modified more than 5 minutes ago
find /home/u20806/public_html -name "robots.txt" -o -maxdepth 1 -mmin +5 -type f -name "*.txt" -delete
rename file extensions for files with specific extension in the current folder
find . -name '*.andnav' -exec sh -c 'mv "$0" "${0%.andnav}.tile"' {} \;z
Send SIGTERM signal to last process sent to background by the current shell.
kill $!
Remove all files from the current directory tree whose names end in "~"
find -iname '*~' | xargs rm
display the long listing of all files in /var/log which were modified 60 days or more ago.
find /var/log/ -mtime +60 -type f -exec ls -l {} \;
Find all directories under current directory and set read-write-execute permission for owner, read-execute permission for group and execute permission for other for those directories
find . -type d -exec chmod u=rwx,g=rx,o=x {} \;
remove all the ".core" files in the file system
find / -name "*.core" | xargs rm
Set 644 permission to all regular files under current directory
chmod 644 `find . -type f`
Copies all files under current directory like '*FooBar*' to the '~/foo/bar' directory.
find -name '*FooBar*' -print0 | xargs -0 cp -t ~/foo/bar
Search the home directory tree for files last modified more than a year ago
find $HOME -mtime +365
List current directory, waiting for user input at each page.
ls | more
Enables shell options 'expand_aliases', 'extglob', 'xpg_echo'.
shopt -s expand_aliases extglob xpg_echo
Removes all empty folders under current folder.
find . -type d -empty -exec rmdir "{}" \;
List all non-empty files under under current directory
find . -type f ! -size 0
Find all *.epub, *.mobi, *.chm, *.rtf, *.lit and *.djvu files/directories under current directory
find ./ -name '*.epub' -o -name '*.mobi' -o -name '*.chm' -o -name '*.rtf' -o -name '*.lit' -o -name '*.djvu'
Read a line from standard input in an interactive shell into variable "input" with prompt "Do that? [Y,n]" and suggestion "Y"
read -e -p "Do that? [Y,n]" -i Y input
Find all the files that were modified more than one day ago
find . -mtime +1
set alias "killaf" for command "kill -9 `psu|grep MF1pp|grep -v grep|awk '{print $2}'`"
alias killaf="kill -9 `psu|grep MF1pp|grep -v grep|awk '{print $2}'`"
display all file in the home folder except ".c" files
find $HOME \! -iname "*.c" print
Recursively print all directories in the current directory tree
tree -d
Make a list of regular files from the current directory tree that have more than 1 link and view it with the "less" pager
find . -type f -noleaf -links +1 -printf "%n %i %f\t%h\n" | sort | less
Display all lines in 'file' containing 'something', pausing for user input after each page.
grep something file | more
Find all *.jpg files under current directory and print only duplicate names
find . -name \*.jpg -exec basename {} \; | uniq -d
Find files matching the pattern "./sr*sc" in their paths under current directory
find . -path "./sr*sc"
List all regular files under current directory ensuring white space safety
find . -type f -print0 | xargs -0 -n 1
Print numbers from 1 to the number in variable "$1"
seq $1
Disable wildcard expansion and name globbing
set -f
Save a list of all 755 permission files/directories under $dir directory tree to the variable 'files'
files="$"
Find all files/directories that start with 'onlyme' in their names under maximum 2 levels down the current directory
find . -maxdepth 2 -name 'onlyme*'
Find all regular files under current directory tree that were accessed $FTIME days ago
find . -type f -atime $FTIME
Find all files in the current directory tree containing "foo" in their names
find . -print | grep -i foo
Archive all ".txt" files in the current directory to "/path/to/dest" keeping partially transferred files
rsync -aP --include=*/ --include=*.txt --exclude=* . /path/to/dest
Descend into every directory under /etc and print the file/directory names with relative paths
find /etc -execdir echo "{}" ';'
display all the files in the home folder which belong to the suer "bruno" and end with ".sxw" and have been accessed in the last 3*24 hours
find /home -type f -name *.sxw -atime -3 -user bruno
Generate the obsolete 29 character Spanish alphabet and number each character
echo -e {{a..c},ch,{d..l},ll,{m,n},ñ,{o..z}}"\n" | nl
list regular files ending in .mbox
find . -type f -wholename \*.mbox
Move "tobecopied/tobeexclude" to "tobeexclude"
mv tobecopied/tobeexclude tobeexclude;
Find all files under ${searchpath} that match the regex ${string1}.*${string2}.*${string3} in their contents where ${string1} etc.. will be expanded
find "${searchpath}" -type f -print0 | xargs -0 grep -l -E "${string1}.*${string2}.*${string3}"
Search the .java files from the current directory tree for TODO lines
find . -name "*.java" -exec grep -i -n TODO {} \;
remove all the permissions for others to all the files in the current folder which have read,write,execute access to users,group and others.
find * -perm 777 -exec chmod 770 {} \;
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
search for the word "nutshell" or "Nutshell" in all the files in the folder book
find /book -print | xargs grep '[Nn] utshell'
Reconnect to a named screen session
screen -R -O -t mysession -S mysession -f
recursively change owner and group of the directory /your/directory/to/fuel/ and all files into it to user and group nginx
chown nginx:nginx /your/directory/to/fuel/ -R
Find the largest original ".gz" file in the current directory tree
find . -name '*.gz' -print | xargs gzip -l | awk '{ print $2, $4 ;}' | grep -v '(totals)$' | sort -n | tail -1
Display a long listing of all files/directories named 'file' under current directory tree
find -name file -ls
Find all executable files
find / -perm /a=x
change the word "GHBAG" to "stream-agg" in all the file names in current folder which have the word "-GHBAG-" in their name
find . -name '*-GHBAG-*' -exec rename 's/GHBAG/stream-agg/' {} +
Remove all white space from "infile.txt" and wrap each line to 80 characters
cat infile.txt | tr -d "[:space:]" | fold -80
Search the current directory tree for hidden files
find .*
Find files in the current directory tree whose size is 24000 bytes
find . -size 24000c
Count all directories in maximum 1 level down the current directory
find . -maxdepth 1 -type d -exec ls -dlrt {} \; | wc --lines
Lookup information of the current user
finger `whoami`
Set the setup connection timeout to 10 seconds for connecting to "<hostName>" via ssh
ssh -o ConnectTimeout=10 <hostName>
Print the drive and mount point of the last mounted drive
mount | tail -1 | sed 's/^.* on \(.*\) ([^)]*)$/\1/'
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'
Find all files in the directory $directory or below with the permissions specificed by $permissions.
find "$directory" -perm "$permissions"
Finds all files in $LOCATION, prints file names, overwrite files with random content $TIMES times, and finally remove them.
find $LOCATION -print -exec shred $TIMES -u '{}' \;
set alias "cleanup" for command 'rm -Rf `pwd`/{foo,bar,baz}'
alias cleanup='rm -Rf `pwd`/{foo,bar,baz}'
Search all Python files in the current directory tree for string "import antigravity"
find . -name "*.py" | xargs grep 'import antigravity'
find all the files in the entire file system which have been modified in the last 120 hours
find / -mtime -5 -print
Recursively set the file access control list of "app/cache" and "app/logs" to rwx for the current user and for user "www-data"
sudo setfacl -R -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
Print variable "$opt" with double quotes deleted
echo "$opt" | tr -d '"'
Delete all files with '.old' extension under current directory tree
find . -name “*.old” -print | xargs rm
Set permissions to 700 for every subdirectory of the current directory
find . -mindepth 1 -type d -print0 | xargs -0 chmod -R 700
Display detailed usage help of the 'cp' command.
cp --help
Delete all contents form the files that contain the regex 'string' in maximum 1 level down the / directory excluding other partitions
find / -maxdepth 1 -xdev -type f|xargs grep -l 'string'| xargs perl -pi -e 's/.//g'
Change permissions to 500 for all regular files under and below the current directory
find . -type f -exec chmod 500 {} ';'
From a script, output the name of the script itself, without containing directories.
basename $0
find all the files in the folder Musica and display them in a single line null separated
find Música/* | egrep -Z \/\\. | xargs -0 echo
Change the ownership to eva for all files/directories that belong to the user 'george' in the entire file system without traversing to other devices/partitions
find -x / -user george -print0 | xargs -0 chown eva
Find all directories under current directory excluding directories that start with a . in their names
find -type d -a ! -name '.?*' -o ! -prune
Find *.c files under $HOME and search for the string 'sprintf' in those files
find $HOME -name '*.c' -print | xargs grep -l sprintf
Find files/directories under '/usr' directory tree that are newer than /tmp/stamp$$ by modification time
find /usr -newer /tmp/stamp$$
create a back up of several folder
find etc home apps -depth -print | cpio -ov > dev/rmt0
Find all files named 'test' in the current directory tree, not descending into "test" directories
find . -name test -prune
Display a long listing of all the regular files in the file system which belong to user 'root' and which have suid bit set
find / -type f -user root -perm -4000 -exec ls -l {} \;
Print the input "hello world" followed by a swap of the first two awk fields
echo hello world | tee >(awk '{print $2, $1}')
Search all the regular files in the current directory for "example"
find -maxdepth 1 -type f | xargs grep -F 'example'
Prints long listing of file 'file.ext'.
ls -al file.ext
Print as many dots as there are files named "file.ext" in the /home/kibab directory tree
find /home/kibab -name file.ext -exec echo . ';'
Dump "FILENAME" as 2 byte wide hexadecimal numbers
od -tx2 FILENAME