nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Compare "$source_file" and "$dest_file" line by line | diff "$source_file" "$dest_file" |
Remove trailing white spaces from all *.rb, *.html, *.js, *.coffee, *.css, *.scss, *.erb, *.yml, *.ru files under current directory | find . \( -name *.rb -or -name *.html -or -name *.js -or -name *.coffee -or -name *.css -or -name *.scss -or -name *.erb -or -name *.yml -or -name *.ru \) -print0 | xargs -0 sed -i '' -E "s/[[:space:]]*$//" |
Displays calendar for a previous, current and next month. | cal -3 |
Print the user name of the current user | echo `whoami` |
Print only unique lines in files 'set1' and 'set2' | cat set1 set2 | sort -u |
Find all files in the current directory and its sub-directories that have been modified sometime in the last 24 hours. | find . -mtime -1 -prin |
Receive pattern to search for on the standard input and print only matching part of lines from file 'f.html' | cat f.html | grep -o \ |
List the full path of each directory under the current working directory | tree -dfi "$" |
find all the files that have been modified in the last 2 days | find . -type f -daystart -mtime -2 |
Search for all files in the current directory recursively whose names contain "linkin", ignoring the case | find . -iname *linkin* |
List only file names matching "*2012*" from "serveripaddress::pt/dir/files/" listening on port 111 and write to "output.txt" | sync --list-only --include "*2012*.xml" -exclude "*.xml" serveripaddress::pt/dir/files/ --port=111 | awk '{ $1=$2=$3=$4=""; print substr; }' >output.txt |
Copy all files below the current directory whose names contain "FooBar" to directory foo/bar/ in user's home directory. | find -name '*FooBar*' -print0 | xargs -0 cp -t ~/foo/bar |
Save the current time formatted according to the format string "%Y-%m-%d %H:%M:%S" to the variable 'CDATE' | CDATE=$(date "+%Y-%m-%d %H:%M:%S") |
Search the /var/www/ tree for files owned by root or unknown group and change their group to 'apache' | find /var/www -group root -o -nogroup -print0 | xargs -0 chown :apache |
Print the names of all hidden regular files from the current directory | find . -maxdepth 1 -type f -name '.*' -exec basename {} \; |
Finds IP address of system network interface, that belongs to 192.168.111 subnet. | ifconfig | grep 192.168.111 | awk '{print $2}' |
List files in the current directory tree which have permissions rwx for user and rw for group and others | find . -perm 766 -exec ls -l {} \; |
Print a colon-separated list of all directories from the ~/code directory tree, except hidden ones | find ~/code -type d -name '[^\.]*' | tr '\n' ':' | sed 's/:$//' |
Search the current directory tree for executable files | find . -type f -executable -print |
For every cron job with a comment "change-enabled" at the end of its crontab entry, change the scheduled hour to 7. | crontab -l | sed -re '/# *change-enabled *$/s/^([^ ]+) [^ ]+/\1 7/' | crontab - |
find the file "httpd.log" in the folder /home/web-server/ | find /home/web-server/ -type f -name httpd.log |
display all the files in the current folder which have been modified in the last 24 hours | find . -mtime -1 |
Filters out strings beginning with '#' from all files in current folder, and prints file name before each line. | cd /var/cron/tabs && grep -vH ^# * |
Compress "my_large_file" with gzip and split the result into files of size 1024 MiB with prefix "myfile_split.gz_" | gzip -c my_large_file | split -b 1024MiB - myfile_split.gz_ |
Remove all directories called "test" from the current directory tree | find -path "*/test" -type d -delete |
Create a ssh key of RSA type, and prompt for a filename to store it, presenting the default for this type of key as $HOME/.ssh/id_rsa | ssh-keygen -t rsa |
exclude vendor and app/cache dir, and search name which suffixed with php | find . -name *.php -or -path "./vendor" -prune -or -path "./app/cache" -prune |
Print virtual memory usage of all processes owned by "jbos[s]" | ps axu | grep jbos[s] | tr -s ' ' | cut -d' ' -f5 |
Print the largest 20 files under current directory | find . -type f -printf '%s %p\n' | sort -rn | head -20 |
set alias "foo" for command "BAR=baz" | alias foo=BAR=baz |
display the number of lines in all the files in the current folder | find . -exec wc -l {} \; |
Find all files/directories under /var/www/some/subset and change their owner and group to www-data | sudo find /var/www/some/subset -print0 | xargs -0 chown www-data:www-data |
Delete all files under /path/to/input/ that match the case insensitive string literal '[email protected]' in their contents | find /path/to/input/ -type f -exec grep -qiF [email protected] \{\} \; -delete |
Save "something" into variable "param" in ksh | echo something | read param |
Remove all libEGL* files from the current directory tree | find . -name libEGL* | xargs rm -f |
Find all Executable files in the file system | find / -perm /a=x |
display all normal/regular files in the folder "$ORIG_DIR" | find "$ORIG_DIR" -name "*" -type f |
Recursively changes group ownership of everything within '.git' to 'git'. | chgrp -R git .git |
List each unique case insensitive character in "file" prefixed by number of occurrences | grep -o . file | sort -f | uniq -ic |
Find all files with name ending with .txt and display only the filenames without full paths | find ./ -name "*.txt" | rev | cut -d '/' -f1 | rev |
display all files in the folder bar only in the path /foo/bar/myfile | find bar -path /foo/bar/myfile -print |
set alias "cd-" for command 'cd $' | alias cd-='cd $' |
Move "$PHANTOM_JS" to "/usr/local/share" directory | sudo mv $PHANTOM_JS /usr/local/share |
Recursively change the owner to "$USER" and group to "$GROUP" of "/var/log/cassandra" | sudo chown -R $USER:$GROUP /var/log/cassandra |
copy all the mp3 files from current folder to another folder | find . -name '*.mp3' -exec cp -a {} /path/to/copy/stuff/to \; |
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}:"{}" \; |
Find regular files in the current directory tree that are called FindCommandExamples.txt and remove them | find . -type f -name "FindCommandExamples.txt" -exec rm -f {} \; |
Find all files/directories under current directory and print them | find . -print0 | xargs -I{} -0 echo {} |
Print out every command that is executed in the script | set -x |
Copies ${FILE} to COLLECT folder with unique name formatted like 'job_XXXXXXXXX'. | cp "${FILE}" "COLLECT/$(mktemp job_XXXXXXXXX)" |
Search the current directory tree for symbolic links named "link1" | find . -type l -name link1 |
Find all files/directories under current directory | find ./ |
Recursively finds all files older than 7 minutes under the current directory, saves list of found files, and compresses them, executing at most 10 compress process at a time. | find . -type f -mtime +7 | tee compressedP.list | xargs -I{} -P10 compress {} & |
Extracts single file 'filename' from bzip2-compressed tarball archive.tbz. | bzip2 -dc archive.tbz | tar xvf - filename |
Find files that don’t have 644 permissions | find / -type f ! -perm 644 |
Send reverse requests to get domain name for each address in 'my_ips' list | cat my_ips | xargs -i dig -x {} +short |
Execute commands from "$file" in the current shell. | source "$file" |
Print all unique strings in $1.tmp file. | cat $1.tmp | sort -u |
Print the contents of "foo.txt" starting with line 2 | tail -n +2 foo.txt |
Calculate md5 sum of empty string | echo -n | md5sum |
Unzip "file.gz", list the unique lines matching regex pattern '"searchstring":"[^"]*"' prefixed by the number of occurrences, sort from least frequent to most frequent | zcat file.gz | grep -o '"searchstring":"[^"]*"'| sort | uniq -c | sort -n |
find all files that have been used more than two days since their status was last changed | find -used +2 |
Request IP address for each domain name received on the command input | dig +short -f - | uniq |
Find all files that have either a .php or a .js extension | find -regextype posix-egrep -regex '.*(php|js)$' |
Exit the shell on the first error encountered | set -e |
Delete all files beneath the current directory that begin with the letters 'Foo'. | find . -type f -name "Foo*" -exec rm {} \; |
Print the files in the current directory as a list of semicolon separated values | ls -1b | tr '\n' ';' |
Set file permission to 664 and directory permission to 775 for all files and directories under htdocs | find htdocs -type f -exec chmod 664 {} + -o -type d -exec chmod 775 {} + |
Find all files under ${searchpath} that match the regex '"${string1}".*"${string2}".*"${string3}"' (${string1} ... won't be expanded) in their contents | find `echo "${searchpath}"` -type f -print0 | xargs -0 grep -l -E '"${string1}".*"${string2}".*"${string3}"' |
Print variable "$OPTARG" "$opt" times | yes "$OPTARG" | head -$opt |
date --date="222 days ago" +"%m" | Prints what month it was 222 days ago |
Prints process tree of a cron process with command arguments and process id number. | pstree -ap `pidof cron` |
Search the current directory tree for regular files whose names match pattern $x | find . -type f -name $x |
search for all the regular files in the current folder and display the contents | find . -type f -exec cat {} \; |
Find all test.txt files/directories under current directory | find . -name test.txt |
Set permissions to ug=rw,o= for files inside the ./default/files tree | find ./default/files -type f -exec chmod ug=rw,o= '{}' \; |
Set permissions for all regular files under /var/www to 755 | find /var/www -type f -print0 | xargs -0 chmod 644 |
Find all files matching shell pattern "foo/bar" in the foo directory tree | find foo -path foo/bar -print |
Count all the lines of code in the current directory recursively. | find ./ -type f -exec wc -l {} \; | cut -d' ' -f1 | paste -sd+ | bc |
Page through a list of all running processes on the system, with those taking most CPU at the top of the list. | ps -eo pcpu,pid,user,args | sort -r -k1 | less |
Find all PHP files under current directory that contain only one line | find -name '*.php' -exec bash -c '[[ "$" -eq 1 ]] && echo "$0"' '{}' ';' |
Prints latest modified file in a directory | ls -1t | head -1 |
Print a single line of numbers from "001" to "100" | yes | head -n 100 | awk '{printf}' |
Copies all files with "FooBar" in the path under the current directory to the '~/foo/bar' directory. | find . | grep FooBar | xargs -I{} cp {} ~/foo/bar |
set alias "foo" for command "$'echo A \'*\' is born at $'" | alias foo=$'echo A \'*\' is born at $' |
search for all the files in the entire file system which have either suid or sgid bit enabled and find of diff of these files with the file "files.secure". | find / \( -perm 2000 -o -perm 4000 \) -print | diff - files.secure |
Print input "your, text, here" formatted to fit 70 characters per line breaking at spaces | echo 'your, text, here' | fold -sw 70 |
Find all files and directories starting from the current directory | find . |
find all the foo.txt files in the current folder and move them to another directory | find . -name "foo.txt" | awk '{ print "mv "$0" ~/bar/" | "sh" }' |
Compress "hello world" and save to variable "hey" | hey=$ |
Rename all "thumbs" directories to "thumb" in the current directory tree | find . -type d -exec rename 's/^thumbs$/thumb/' {} ";" |
find all files in the current folder that end with ",txt" | find . -name "*,txt" |
Request changing the passphrase of key file "private.key" | ssh-keygen -pf private.key |
Archive all *.1 files/directories to each filename.tgz files and remove the original source | find *.1 -exec tar czf '{}.tgz' '{}' --remove-files \; |
Send SIGWINCH process to current shell, causing it to update the LINES and COLUMNS variables which describe the size of the screen/window in characters. | kill -s WINCH $$ |
Print summary of new/missing files, and which files differ between folder1 and folder2. | diff -arq folder1 folder2 |
Find all files in the current directory tree whose size is greater than 1MB, and move them to the "files" folder | find . -size +1M -exec mv {} files \+ |
Find all *.rb files/directories under current directory | find . -name *.rb |
Recursively change owner to "www-data" of "/var/www/.gnome2", "/var/www/.config", and "/var/www/.config/inkscape" | chown -R www-data /var/www/.gnome2 /var/www/.config /var/www/.config/inkscape |
Resolve any symlinks in working directory, and go to resulting pathname. | cd "`pwd -P`" |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.