nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Search the current directory recursively for regular files, skipping hidden files in the current directory | find * -type f -print |
find all the jpg files in current folder and sort them | find . -type f|grep -i "\.jpg$" |sort |
Print a listing of the /usr/local/etc/rc.d directory tree | find /usr/local/etc/rc.d -type f | awk -F/ '{print $NF}' |
find all files under the current directory that end in "foo" and, using xargs, execute somecommand once for each filename found | find . -name '*.foo' -print0 | xargs -0 -n 1 somecommand |
List all hidden files under present working directory and redirect the list to all-hidden-files.txt | find `pwd` -iname ".*" -type f > all-hidden-files.txt |
Convert relative symbolic link "$link" to absolute symbolic link | ln -sf "$(readlink -f "$link")" "$link" |
Run the command 'true' with an empty environment variable doFirst | doFirst= true |
Read a single character from standard input into variable "REPLY" ignoring backslash escapes and using the prompt "${1:-Continue?} [y/n]: " | read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY |
Look for files with wide open permissions | find . -type f -perm 777 -exec ls -l {} \; |
Find regular files modified within the last ten minutes under /etc | find /etc -type f -mmin -10 |
Recursively copies all files in the current directory but ones with 'c' in name to the home directory. | cp -r `ls -A | grep -v "c"` $HOME/ |
Split "list.txt" into files with at most 600 lines each | split -l 600 list.txt |
Change permissions to u=rwx,g=rx,o= for all directories inside the current directory tree | find . -type d -exec chmod u=rwx,g=rx,o= '{}' \; |
Find all regular files with permissions 777 under and below /home/user/demo/, and change their permissions to 755 | find /home/user/demo -type f -perm 777 -print -exec chmod 755 {} \; |
Show all values (without the names) of variables whose name or value contains "VARIABLE_NAME" | set | grep VARIABLE_NAME | sed 's/^.*=//' |
List the files from the current directory tree that contain lines matching regular expression '^Subject:.*unique subject' | find . -type f -print0 | xargs -0 grep -il '^Subject:.*unique subject' |
Print the contents of "xx.sh" | cat xx.sh |
Print a randomly sorted list of numbers from 1 to 10 to file "/tmp/lst" and the screen followed by " -------" | seq 1 10 | sort -R | tee /tmp/lst |cat <(cat /tmp/lst) <(echo '-------') |
Save the md5 sum hash of "$my_iso_file" to variable "md5" | md5=$(md5sum "$my_iso_file" | cut -d ' ' -f 1) |
Write the output of "false" to standard output and to "/dev/null" | false | tee /dev/null |
Find all *FooBar* files/directories under current directory and copy them to ~/foo/bar | find -name '*FooBar*' -print0 | xargs -0 cp -t ~/foo/bar |
Find "*prefs copy" files in the /mnt/zip directory tree and remove them with prompting | find /mnt/zip -name "*prefs copy" -print0 | xargs -p rm |
display long listing of all the text files in the current folder and then execute the script myScript.sh by passing the output of previous exec as input | find . -name "*.txt" -exec ls -la {} \; -exec ./myScript.sh {} \; |
display all the regular files in the current folder excluding those that are present in the path "git" | find . -path "*.git" -prune -o -type f -print |
Find all leaf directories that include only one occurrence of "modules" | find -regex '.*/modules\(/.*\|$\)' \! -regex '.*/modules/.*/modules\(/.*\|$\)' -type d -links 2 |
Prints long listing of ${0} file. | ls -l ${0} |
Set shell option 'dotglob'. | shopt -s dotglob |
Search three folders named foo, bar, and baz for all "*.rb" files | find foo bar baz -name "*.rb" |
Archive "source" to "destination" via ssh with "rwX" permissions | rsync -rvz --chmod=ugo=rwX -e ssh source destination |
find the file "fluidpoint" in the file system and discard all the errors | find / -name fluidpoint 2> /dev/null |
Print directories in the the current directory as a list with no report information | tree -d -L 1 -i --noreport |
create directory /etc/cron.5minute | mkdir /etc/cron.5minute |
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 |
Remove all *.log files from the current directory tree | find ./ -name '*.log' -print0 | xargs -0 rm |
create directories bravo_dir and alpha_dir | mkdir bravo_dir alpha_dir |
Recursively finds strings with"text string to search” in files under 'directory-path', regarding provided options '[option]'. | grep [option] "text string to search” directory-path |
Find all *.txt files under the current directory whose names are not "File.txt" | find . -maxdepth 1 -type f -regex '.*\.txt' -not -name File.txt |
Find all files/directories with '.err' extension under '/home/username' directory tree | find /home/username/ -name "*.err" |
Delete all directories under '.cache/chromium/Default/Cache/' directory tree that are bigger than 100MB and are at least 1 level deep | find .cache/chromium/Default/Cache/ -mindepth 1 -type d -size +100M -exec rm -rf {} \; |
search for the word error in all the xml files in the current folder | find . -name "*.xml" -exec grep "ERROR" /dev/null '{}' \+ |
List recursively all files and directories in /var/www | find /var/www |
Find all files/directories owned by user 'michel' under current directory | find -user michel |
Find all the files which are greater than 50MB but less than 100MB in size | find / -size +50M -size -100M |
run a shell as user jenkins | su - jenkins -s /bin/bash |
Print '111 22 3\n4 555 66\n' by replacing the spaces with tabs and '\n' with newlines | echo -en '111 22 3\n4 555 66\n' | tr ' ' '\t' |
Find all files/directories under current directory tree that have modified in the last 2 days and contain 'blah' in their names | find . -iname '*blah*' \ -mtime -2 |
Archive files in "sorce_dir" to "target_dir" | rsync -a --filter="-! */" sorce_dir/ target_dir/ |
Print the output of history without line numbers | history|awk '{$1="";print substr($0,2)}' |
Read a line from standard input into variable "response" without backslash escapes using the prompt "About to delete all items from history that match \"$param\". Are you sure? [y/N] " | read -r -p "About to delete all items from history that match \"$param\". Are you sure? [y/N] " response |
Check if "/path/to/dir" is a nfs mount point | mount -l | grep 'type nfs' | sed 's/.* on \([^ ]*\) .*/\1/' | grep /path/to/dir |
Search the current directory tree for .rb files ignoring the "./vendor" subdirectory | find . -name '*.rb' ! -wholename "./vendor/*" -print |
Create a symbolic link named "temp" to "newtarget" | ln -s newtarget temp |
Create a bzip2 archive of all .log files from the /var/log directory tree | find /var/log -name '*.log' | tar cv --files-from=- | bzip2 > log.tar.bz2 |
Search for all .mp3 files in the /mnt/usb directory tree | find /mnt/usb -name "*.mp3" -print |
Find all files/directories named 'top' in the entire filesystem | find / -name top |
create symbolic links in current directory to all files located in directory "/original" and have filename extension ".processname" | find /original -name '*.processme' -exec echo ln -s '{}' . \; |
Find all build* directories under current directory and reverse sort them | find . -type d -name "build*" | sort -r |
Infinitely print "1" then "0" | yes 0 | sed '1~2s/0/1/' |
Find files/directories under current directory and print them | find . -print0 | xargs -0 echo |
run command "/path/to/my_daemon" as user joe and redirect the output to file /some/output/file | su - joe -c "/path/to/my_daemon > /some/output/file" & |
split content all files file1..40000 into pieces per 1445 lines named as outputprefixNNN as digital prefix | cat file1 file2 ... file40000 | split -n r/1445 -d - outputprefix |
Display the content of YourFile.txt, waiting for user input at each page. | more YourFile.txt |
Print all business days in the current month without column titles | cal -h | cut -c 4-17 | tail -n +3 |
Print the minimum transmission time of 10 ping requests to "google.com" from cygwin | ping google.com -n 10 | grep Minimum | awk '{print $3}' | sed s/,// |
Prints $m latest modified files within the $d folder, using $f format for printing timestamp. | find "$d" -type f -printf "%T@ :$f %p\n" | sort -nr | cut -d: -f2- | head -n"$m" |
Print a minimal set of differences between files in directories "teste1" and "teste2", treat absent files as empty, ignore differences in whitespace, treat all files as text, and print 3 lines of unified context | diff -burNad teste1 teste2 |
Execute "ls" every 2 seconds | watch ls |
Recursively print all files and directories in the current directory tree including hidden files | tree -a . |
Execute command "tssh MYBOXES N" where N ranges from 0 to 20 | seq 0 20 | xargs -n1 tssh MYBOXES |
recursively change owner of directories $/lib $/node_modules $/bin $/share to the current user | sudo chown -R $ $/{lib/node_modules,bin,share} |
Find all files/directories named 'pattern' under current directory tree | find . -name "pattern" -print |
replace the word foo to bar in all the regular/normal files in the current folder (does not update the file) | find . -type f -exec sed -i 's/foo/bar/g' {} + |
display list of all the regular/normal files in the home folder which are exactly 6579 bytes | find /home/ -type f -size 6579c -exec ls {} \; |
Report file system containing /example disk usage in kilobytes. | df -k /example |
Create ssh tunnel through "genja.org" connecting localhost port 4444 to "raptor.lan" port 22 | ssh -L 4444:raptor.lan:22 genja.org |
Format "file.txt" as space separated columns 28 characters in width | cat file.txt | column -c 28 -s "\ " |
Count the number of .gz files in the current directory tree | find -name "*.gz" | wc -l |
find 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/*" |
Find all regular files with 400 permission under '/data' directory tree | find /data -type f -perm 400 -print |
Find all files newer than httpd.conf under and below the current directory | find . -newer httpd.conf |
Find *.html files in the current directory tree that were modified 7 days ago | find . -mtime 7 -name "*.html" -print |
find all files in the folder /etc which have been modified after /tmp/foo | find /etc -newer /tmp/foo |
Gets list of IP addresses of all network interfaces. | ifconfig | awk -F"[ :]+" '/inet addr/ && !/127.0/ {print $4}' |
display all directories in current folder and do not search in sub directories | find . -maxdepth 1 -mindepth 1 -type d |
Find all files under /mnt/naspath directory without descending into .snapshot directory that were modified in last 24 hours with null character as the delimiter | find /mnt/naspath \! \(-name .snapshot -prune\) -type f -mtime 0 -print0 |
Recursively change all permissions under "theDirectory/" to 777 | sudo chmod -R 777 theDirectory/ |
Sort file pointed by variable $filename, removing duplicate entries but ignoring the last N characters of each line. | rev $filename | sort | uniq -f=N | rev |
Convert the contents of "infile" from dos to unix style text and display the result as printable characters or backslash escapes | cat infile | dos2unix -U | od -c |
display all files in current folder excluding those that have the word "git" in their name and display files that have git in their path names | find . ! -name '*git*' | grep git |
Find all files with '.conf' extension under '/etc' directory tree that have been modified in the last 30 minutes | find /etc -name "*.conf" -mmin -30 |
Find all *.txt file (case insensitive) in the entire system and copy them to /tmp/txt | find / -iname '*.txt' | xargs --replace=@ cp @ /tmp/txt |
Read a line from standard input with prompt "Are you sure? [Y/n]" and save response in variable "response" | read -r -p "Are you sure? [Y/n]" response |
Remove all vmware-*.log files under current directory | find . -name vmware-*.log | xargs rm |
Find which ruby files under current directory contain the string 'jump' | find . -name '*.rb' -exec grep -H jump {} \; |
Recursively finds strings like "texthere" in all "*.txt" files of a current folder. | grep -r --include "*.txt" texthere . |
Set the permissions of all directories inside the current directory tree to u=rwx,g=rx,o=x | find . -type d -exec chmod u=rwx,g=rx,o=x {} \; |
Find all files in the home directory tree that are owned by another user and change their ownership to the current user | find ~ ! -user $USER -exec sudo chown ${USER}:"{}" \; |
display all directories in the folder "PROD" and do not search in the sub directories | find /PROD -maxdepth 1 -type d |
Search for 'mystring' in all *.txt files under current directory | find . -name "*.txt" -print0 | xargs -0 egrep mystring |
Find all files/directories named 'text' under current directory | find -name "text" |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.