nl
stringlengths
13
387
bash
stringlengths
1
532
download a file "http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip" using cookies "oraclelicense=accept-securebackup-cookie"
curl -L -C - -b "oraclelicense=accept-securebackup-cookie" -O http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip
download content from "http://127.0.0.1:8000" and output to "index.html"
curl http://127.0.0.1:8000 -o index.html
download contents from "https://raw.github.com/creationix/nvm/master/install.sh" and execute
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
download contents from "https://www.npmjs.com/install.sh" and execute
curl https://www.npmjs.com/install.sh | sh
download contents of a website "https://get.scoop.sh"
curl -L https://get.scoop.sh
Dump "/dev/ttySomething" in both hex and text
od -t x1 -t a /dev/ttySomething
Dump "filename" as 2 byte wide hexadecimal and printable characters
od -xc filename
Dump "testscript.sh" as 2 byte hexadecimale, printable characters, and octal values
od -xcb testscript.sh
Dump the character output of "echo 'hi'"
echo 'hi' | od -c
Dump the character output of 'echo `echo "Ho ho ho"`'
echo `echo "Ho ho ho"` | od -c
Duplicate directory tree under /mnt/usr/lib to /usr but creating symlinks to files instead of copying them.
cp -rs /mnt/usr/lib /usr/
Edit the cron job list for user 'wwwrun' using default editor specified by the EDITOR environment variable, or /usr/bin/editor if no default editor is specified.
sudo crontab -u wwwrun -e
Edit current user's cron job list with editor specified by EDITOR environment variable, or default /usr/bin/editor if EDITOR is not set.
crontab -e
Eliminates partially duplicate lines by column, keeping the last occurrence
tac temp.txt | sort -k2,2 -r -u
Enables 'dotglob' shell option.
shopt -s dotglob
Enables 'globstar' (recursive globbing) shell option.
shopt -s globstar
Enables 'nullglob' shell option.
shopt -s nullglob
Enables shell option 'autocd'.
shopt -s autocd
Enables shell option 'cdable_vars'.
shopt -s cdable_vars
Enables shell option 'cmdhist'.
shopt -s cmdhist
Enables shell option 'compat31'.
shopt -s compat31
Enables shell option 'expand_aliases'.
shopt -s expand_aliases
Enables shell options 'expand_aliases', 'extglob', 'xpg_echo'.
shopt -s expand_aliases extglob xpg_echo
Enables shell options 'extglob' and 'progcomp'
shopt -s extglob progcomp
Enables shell option 'failglob'.
shopt -s failglob
Enables shell option 'lastpipe'.
shopt -s lastpipe
Enables shell option 'nullglob'.
shopt -s execfail
Enables shell options 'nullglob' and 'dotglob'.
shopt -s nullglob dotglob
Enables shell option 'promptvars'.
shopt -s promptvars
Ensure all 5 of UEDP0{1..5}_20120821.csv files exist, creating empty files for any missing ones (updates the file's timestamps)
touch -a UEDP0{1..5}_20120821.csv
Erase user's cron jobs and add one cron job to run "script" every minute.
echo "* * * * * script" | crontab -
ERROR - this is for DOS
ping -n 1 %ip% | find "TTL"
ERROR - Probably means -pgoDt (capital D)
sudo rsync -pgodt /home/ /newhome/
ERROR - will overwrite the executable if it's not a symlink.
sudo ln -sf /usr/local/ssl/bin/openssl `which openssl`
Evaluate the output of recursively changing the owner and group of "/data/*" to "mongodb"
`sudo chown -R mongodb:mongodb /data/*`
Exclude directory from find . command
find ! -path "dir1" -iname "*.mp3"
Exclude directory from find . command
find -iname example.com | grep -v beta
Exclude directory from find . command
find -name "*.js" -not -path "./directory/*"
Exclude directory from find . command
find . -name '*.js' -and -not -path directory
Exclude directory from find . command
find . -name '*.js' | grep -v excludeddir
Exclude directory from find . command
find . -path ./misc -prune -o -name '*.txt' -print
Exclude directory from find . command
find . -type d -name proc -prune -o -name '*.js'
Exclude directory from find . command
find ./ -path ./beta/* -prune -o -iname example.com -print
Exclude directory from find . command
find build -not \( -path build/external -prune \) -name \*.js
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
Execute "${MD5}" on all files found under "${1}", numerically sort the results, and save to variable "DATA"
DATA=$( find "${1}" -type f -exec ${MD5} {} ';' | sort -n )
Execute "date" every second
watch -n 1 date
Execute "du -s path" every 300 seconds
watch -n 300 du -s path
Execute "ls -l data.temp" every 2 seconds
watch ls -l data.temp
Execute "ls -l" every 0.5 seconds
watch -n 0.5 ls -l
Execute "ls -l" every 2 seconds
watch 'ls -l'
Execute "ls -l" every 2 seconds
watch ls -l
Execute "ls -l" every 2 seconds and highlight the differences in runs
watch -d ls -l
Execute "ls -l" on host "something" as user "root"
ssh root@something 'ls -l'
Execute "ls" every 2 seconds
watch ls
Execute "ls" every second
watch -n 1 ls
Execute "ps -C java -o pcpu,state,cputime,etimes" every second
watch -n 1 ps -C java -o pcpu,state,cputime,etimes
Execute "wget -qO- http://fake.link/file.txt" every 5 seconds
watch -n 5 wget -qO- http://fake.link/file.txt
Execute 'echo -e "\033[31mHello World\033[0m"' every without color support 2 seconds
watch 'echo -e "\033[31mHello World\033[0m"'
Execute 'echo -e "\tHello World"' every 2 seconds
watch 'echo -e "\tHello World"'
Execute `echo' for each file found
find . | xargs -n 1 echo
Execute `find -type f | egrep -i "(jpg|bmp|png|gif)$"` every 300 seconds and display without title
watch -n 300 -t `find -type f | egrep -i "(jpg|bmp|png|gif)$"`
Execute /usr/bin/find with $* arguments
/usr/bin/find $*
Execute /usr/bin/find with $* arguments where current directory is the first argument
/usr/bin/find ./ $*
execute command "who" when key "\eW" is pressed
bind -x '"\eW":"who"'
Execute the file utility for each file found under /etc and below
find /etc -print0 | xargs -0 file
Execute the file utility for each file found under /etc or below that contains "test" in its pathname
find /etc -print0 | grep -azZ test | xargs -0 file
Execute the first instance of "parallel" found in the PATH, passing it all parameters received by the script/function
`which parallel` "$@"
Execute md5sum command on files found by the find command
find -iname "MyCProgram.c" -exec md5sum {} \;
Execute python script "test.py" with "LD_PRELOAD=./linebufferedstdout.so" and write the output to console and append to "test.out"
LD_PRELOAD=./linebufferedstdout.so python test.py | tee -a test.out
Execute zcat on every file matching "*20120805.gz" in the current directory and subdirectories
find . -name *20120805.gz -exec zcat {} \;
explicitly list all files in the current directory
find . -print
extract "backup.tar.gz" with verbose output
tar -xzvf backup.tar.gz
extract "filename.tar.xz" with verbose output
$ tar xvfJ filename.tar.xz
extract "passwd.tar.gz" with verbose output
tar -xvzf passwd.tar.gz
extract "phantomjs-1.9.0-linux-x86_64.tar.bz2"
sudo tar xvf phantomjs-1.9.0-linux-x86_64.tar.bz2
extract 'archive.tar.gz' to /destination
gzip -dc archive.tar.gz | tar -xf - -C /destination
extract 'archive.tar.gz' to /destination
tar xzf archive.tar.gz -C /destination
extract /path/to/my_archive.tar.xz to /path/to/extract and preserve permissions.
tar xpvf /path/to/my_archive.tar.xz -C /path/to/extract
Extract five digits sequence from a filename with x number of alphanumeric characters followed by the five digit sequence surrounded by a single underscore on either side then another set of x number of alphanumeric characters.
echo 'someletters_12345_moreleters.ext' | cut -d'_' -f 2
Extracts a bz2 file.
bunzip2 file.bz2
Extract and print hostname and protocol part from URL like "http://www.suepearson.co.uk/product/174/71/3816/".
echo "http://www.suepearson.co.uk/product/174/71/3816/" | cut -d'/' -f1-3
Extract any line in "f1" or "f2" which does not appear in the other
comm -3 <(sort -un f1) <(sort -un f2)
Extract any line in "file1" or "file2" which does not appear in the other
comm -3 <(sort file1) <(sort file2)
Extract any line in "file1.txt" which does not appear as the first ";" delimited entry in "file2.txt"
comm -23 <(sort file1.txt) <(grep -o '^[^;]*' file2.txt | sort)
Extract any line in "fileA" which does not appear as the first word of any line in "fileB"
comm -23 <(sort fileA) <(cut -d' ' -f1 fileB | sort -u)
Extract any line in "set1" which does not appear in "set2"
comm -23 <(sort set1) <(sort set2)
extract archive stored in $1
tar -zxvf $1
Extract the contents of "Input.txt.gz", list the unique first comma separated field prefixed by the number of occurrences
zcat Input.txt.gz | cut -d , -f 1 | sort | uniq -c
Extract files from archive 'archive.tar'
cat archive.tar | tar x
Extract path and query part from URL
echo "$url" | cut -d'/' -f4-
Extract protocol and host name from URL.
echo "$url" | cut -d'/' -f1-3
Extract protocol part from URL.
echo "$url" | cut -d':' -f1
Extracts single file 'filename' from bzip2-compressed tarball archive.tbz.
bzip2 -dc archive.tbz | tar xvf - filename
Extract, sort and print only group names from /etc/group.
cut -d: -f1 /etc/group | sort
Fetch 'stackoverflow.com' domain IP addresses from dig DNS lookup
dig stackoverflow.com | grep -e "^[^;]" | tr -s " \t" " " | cut -d" " -f5
File "files.txt" contains a list of files, copy all files listed to host "remote", connecting as ssh user "user", and copying the files to this user's home directory - this will not work with files/directory names containing spaces.
cat files.txt | xargs scp user@remote:
The file "files_to_find.txt" contains a list of filenames, create each file or update its timestamp if it exists.
touch `cat files_to_find.txt`
File 'save_pid.txt' contains a process ID, instantly kill this process with SIGKILL signal.
kill -9 `cat save_pid.txt`
file all the Sticky Bit set files whose permission are 551
find / -perm 1551