nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Report file system containing path to the current working directory inodes usage. | df -i $PWD |
Recursively move all files in "/path/to/srcdir" to "dest/" | find /path/to/srcdir -type f -print0 | xargs -0 -i% mv % dest/ |
Calculate the sum of all the numbers from 1 to 100000 | seq 100000 | paste -sd+ | bc -l |
list names of bind functions containing "/" | bind -l | grep / |
Display hardware platform, ie. x86_64 even if current kernel uses 32-bit addressing. | uname -i |
Search the current directory recursively for text files containing at least one character | find . -type f -exec grep -Iq . {} \; -and -print |
Search for first match of the case insensitive regex 're' in all *.coffee files under current directory and print the file paths along with the matches | find . -print0 -name '*.coffee'|xargs -0 grep -m1 -ri 're' |
Pipe output of "yes" to "more" and append the first 3 lines to "file" | yes | awk 'FNR<4 {print >>"file"; close("file")} 1' | more |
Find files/directories named 'foo.bar' in the root filesystem partition | find / -name foo.bar -print -xdev |
Find all files in the current directory tree whose pathnames match pattern '*/1/lang/en.css' | find . -path ‘*/1/lang/en.css’ -print |
Calculate the md5 sum of all files in the current directory with the filename printed first | find -maxdepth 1 -type f -exec md5sum {} \; | awk '{s=$2; $2=$1; $1=s;}1' |
Mount "/path/to/device" on "/path/to/mount/location" as a loop back device | mount /path/to/device /path/to/mount/location -o loop |
Show the list of all files on the system whose names do not end in ".c" | find / \! -name "*.c" -print |
Simulate a full login | su - |
Change the owner of "/var/www/html/mysite/images/" to "nobody" | sudo chown nobody /var/www/html/mysite/images/ |
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' |
Find all files/directories under current directory tree excluding files/directories with name 'query_to_avoid' | find -not -name "query_to_avoid" |
Display differences between files dir1.txt and dir2.txt. | diff dir1.txt dir2.txt |
Find all *.zip files under current directory and unzip them in the same directory as the files | find . -name '*.zip' -execdir unzip '{}' ';' |
Creates path as current folder path and folder that contains $0 file, and saves result in 'script_dir' variable. | set script_dir = `pwd`/`dirname $0` |
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 |
Print the IP addresses for the current host name | hostname -i |
Search the current directory tree for files whose names do not end in ".exe" and ".dll" | find . -not -name "*.exe" -not -name "*.dll" -not -type d |
Find all files/directories under current directory | find ./ |
Send SIGTERM signal to all 'firefox' processes, requesting them to terminate. | kill `pidof firefox` |
Read a line from standard input into variable "ans" without backslash escapes | read -r ans |
find all instances of a specific file in the entire file system and discard the errors | find / -name expect 2>/dev/null |
Search for 'string_to_find' in all files under current directory | find -type f | sed 's/./\\&/g' | xargs grep string_to_find |
Set variable 'path' to name of current directory (without the containing directories) converted to lowercase. | path=$(basename $(pwd) | awk '{print tolower($0)}') |
change the permissions of all the regular/normal files in the folder "/path/to/someDirectory" to 644 | sudo find /path/to/someDirectory -type f -print0 | xargs -0 sudo chmod 644 |
Find files/directories named 'file.txt' that belong to user 'tutonics' in the entire filesystem | find / -user tutonics -name "file.txt" |
split the file "file" into pieces per 2 lines | split -n2 infile |
list files found under the current directory ending in "txt" or ending in "html" | find . -name '*.txt' -o -name '*.html' |
Search for 'some string' in all *.axvw files under current directory and show the matched lines with line numbers | find . -name '*.axvw' -print0 | xargs -0 grep -n 'some string' |
Read a line from standard input into variable "a" without backslash escapes | read -r a |
search for the folder .dummy and remove it from the folder "Test folder" | find "Test Folder" -type d -name '.dummy' -delete |
Find the directories whose pathnames contain "New Parts" at level 3 of the current directory tree and create symlinks to them in /cygdrive/c/Views | find -mindepth 3 -maxdepth 3 -type d | grep "New Parts" | tr '\012' '\000' | xargs -0 ln -s -t /cygdrive/c/Views |
list all java file that StringBuff in context. | find . -type f -name "*.java" -exec grep -l StringBuffer {} \; |
Recursively removes all files and folders named '.svn' in a current folder. | find . -name .svn -exec rm -rf {} \; |
Find all *Company* files/directories under /root/of/where/files/are directory | find /root/of/where/files/are -name *Company* |
search for the file "foo.txt" in the entire file system | find / -name foo.txt |
Find all socket files in the current directory and its sub-directories. | find . -type s |
Save the absolute path of the current script to variable "SELF" | script="`readlink -f "${BASH_SOURCE[0]}"`" |
Find all files and directories that have been modified in the last seven days. | find . -mtime -7 |
Disables shell option 'dotglob'. | shopt -u dotglob |
Redirect the current process's standard error to standard out and write to console and append to "$HOME/logfile" | exec > > 2>&1 |
Get a recursive file list of directory $dir | find "$dir" -type f |
Saves 'tmux' version in the 'tmux_version' variable. | tmux_version="$" |
Save hexadecimal byte 9 in binary file "file.moi" to variable "month" | month=$(od -t x1 --skip-bytes=8 --read-bytes=1 file.moi | head -1 | awk '{print $2}') |
Calculate md5 sum of empty string | echo -n "" | md5sum |
search for all the directories in a folder and give them as input to the python script | find /stuff -type d -exec script.py {} + |
Search the regular files of the current directory tree for string "whatever" | find . -type f | xargs -L 100 grep whatever |
Get the disk space used by all *.txt (case insensitive) files under /home/d directory | find /home/d -type f -name "*.txt" -printf "%s\n" | awk '{s+=$0}END{print "total: "s" bytes"}' |
Find all SGID files in entire file system | find / -perm +2000 |
Merge colon-separated information from standard input and file1.txt where the first field of both files matches, print unpairable lines from standard input, replace missing fields with "no-match", and output the second field from standard input and the second and third field from file1.txt | join -t, -o 1.2,2.2,2.3 -a 1 -e 'no-match' - <(sort file1.txt) |
search for the file ".user.log" in a folder | find /nfs/office -name .user.log -print |
Find all files/directories with '.o' extension under '/lib/modules' directory tree | find /lib/modules -name '*.o' |
Unzip and untar "file.tar.gz" | zcat file.tar.gz |tar x |
Prints path location of $BASH_SOURCE file. | echo this dir: `dirname $BASH_SOURCE` |
Print a list of all duplicate case insensitive file paths in the current directory tree | find . | sort -f | uniq -i -d |
Identify CMS version/releases accross all your Wordpress websites | find /home/*/public_html/ -type f -iwholename "*/wp-includes/version.php" -exec grep -H "\$wp_version =" {} \; |
Save the system host name in variable "HOSTNAME" | HOSTNAME=$(hostname) |
Find files in two different directories (esofthub and esoft) having the "test" string and list them | find esofthub esoft -name "*test*" -type f -ls |
Print the contents of "xx.sh" | cat xx.sh |
Exclude directory from find . command | find ./ -path ./beta/* -prune -o -iname example.com -print |
search for a word in all the .C files( those having the extension "c") in current directory | find . -type f \( -iname “*.c” \) |grep -i -r “keyword” |
find StringBuffer in all *.java files, ignoring case | find . -type f -name "*.java" -exec grep -il string {} \; |
Find all files under /path/to/base/dir and change their permission to 644 | chmod 644 $(find /path/to/base/dir -type f) |
Add content of "filename" to the existing cron jobs of user "user", without removing the previously existing cron jobs. | crontab -l -u user | cat - filename | crontab -u user - |
find all the text files which are present in the current directory excludinghidden files. | find . -type f \ |
Gets IP address of a primary network interface. | /sbin/ifconfig $ | awk -F: '/inet /{print $2}' | cut -f1 -d ' ' |
Search the files from directory tree "dirname" for string "foo" | find dirname -exec grep foo {} + |
Find files/directories in entire file system that were accessed in less than a day ago | find / -atime -1 |
Remove all files named tmp or ending in .xx that have not been accessed for seven or more 24-hour periods | find / \ -atime +7 -exec rm {} \; |
Find the process currently taking the most CPU time. | top -b -n1 -c | awk '/PID *USER/{print;getline;print}' |
display a long listing of all the files that begin with the name "Metallica" in the entire file system | find / -name 'Metallica*' -exec ls -l {} \; |
Prints the length, line number, and contents of the longest line in myfile | perl -ne 'print length." line $. $_"' myfile | sort -nr | head -n 1 |
Clean the current directory from all subversion directories recursively | find . -type d -name ".svn" -print | xargs rm -rf |
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 |
Print source of the file system containing $path. | df -P $path | tail -1 | cut -d' ' -f 1 |
Move server.log to 'logs' directory with new name as the current date formatted as "%Y%m%d%H%M" and with '.log' extension | mv server.log logs/$(date -d "today" +"%Y%m%d%H%M").log |
Read one character from standard input into variable "REPLY" | read -n1 |
search for all files ending with ".mkv" in current folder | find /volume1/uploads -name "*.mkv" |
Create a ssh key with no passphrase and store it in "outfile". | ssh-keygen -f outfile -N '' |
Print the average time of 4 ping requests to "www.stackoverflow.com" | ping -c 4 www.stackoverflow.com | awk -F '/' 'END {print $5}' |
Find files in the current directory and below that are newer than /bin/sh | find . -newer /bin/sh |
Find all files/directories with '.bar' extension in maximum 2 levels down the current directory | find . -name *.bar -maxdepth 2 -print |
Finds users with X session in system and puts the result into USERS variable | USERS=$(awk '/\/X/ {print $1}' <) |
Find all files under /myfiles with read-write access for others | find /myfiles -type f -perm -o+rw |
Find all files in the file system with the SUID bit | find / -perm -u+s -print |
Searches manual pages which descriptions contain 'postscript', and prints name and description of only ones that contain any-cased 'png' pattern. | apropos postscript | grep -i png |
change the extension of all the files in the current folder to html excluding those html files and those which are present in another disk partition | find . -xtype f \! -iname *.html -exec mv -iv "{}" "{}.html" \; |
Execute 'echo -e "\033[31mHello World\033[0m"' every without color support 2 seconds | watch 'echo -e "\033[31mHello World\033[0m"' |
Finds if environment variable like 'DUALCASE' exists in environment. | env | grep DUALCASE |
display all the jars in the current folder | find . -iname '*.jar' |
Run script `deslash.sh' on all thumb.png files in the current directory tree | find -type f -name thumb.png -exec ./deslash.sh {} ";" |
Read a line from standard input into variable "i" with the prompt " Again? Y/n " | read -p " Again? Y/n " i |
To match only hidden dot directories | find /nas01/backups/home/user/ -type d -name ".*" -print0 -exec ls -lrt {} \; |
Find all *.m4a files/directories under /home/family/Music directory | find /home/family/Music -name *.m4a -print0 |
Change the owner of "/var/www/html/mysite/images/" to "nobody" | sudo chown nobody /var/www/html/mysite/images/ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.