This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Programming Languages

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

Programming languages are formal languages used to write instructions that a computer can execute. They have specific syntax and semantics and are used to develop software, scripts, and applications. Different languages are suited for different tasks, such as web development, system programming, or data analysis. Mastery of multiple programming languages can greatly enhance a developer’s versatility and problem-solving capabilities.

1 - 🖥️bash

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the bash command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗  █████╗ ███████╗██╗  ██╗
#                ██╔══██╗██╔══██╗██╔════╝██║  ██║
#                ██████╔╝███████║███████╗███████║
#                ██╔══██╗██╔══██║╚════██║██╔══██║
#                ██████╔╝██║  ██║███████║██║  ██║
#                ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝
                                                
                                               
															  
															  
#==============================#
# CMD BASH
#==============================##==============================#
# To implement a for loop:
for file in *;
do 
    echo $file found;
done

# To implement a case command:
case "$1"
in
    0) echo "zero found";;
    1) echo "one found";;
    2) echo "two found";;
    3*) echo "something beginning with 3 found";;
esac

# Turn on debugging:
set -x

# Turn off debugging:
set +x

# Retrieve N-th piped command exit status
printf 'foo' | fgrep 'foo' | sed 's/foo/bar/'
echo ${PIPESTATUS[0]}  # replace 0 with N

# Lock file:
( set -o noclobber; echo > my.lock ) || echo 'Failed to create lock file'

# Fork bomb
:(){ :|:& };:

# Unix Roulette
# (Courtesy of Bigown's answer in the joke thread)
# DANGER! Don't execute!
[ $[ $RANDOM % 6 ] == 0 ] && rm -rf /* || echo Click #Roulette

# for loop in one line
for i in $(seq 1 4); do echo $i; done

# Check to see if a variable equals a specified integer
if [ "$var" -eq "0" ]; then
    echo "var equals zero";
fi

# Test if a program exists in the path
# There are false positives: aliases and functions
command -v ${program} >/dev/null 2>&1 || error "${program} not installed"

# Redirection
# Please note that 2>&1 goes after
my_command > command-stdout-stderr.txt 2>&1
my_command > /dev/null 2>&1
# Redirect stdout and stderr of cmd1 to cmd2
cmd1 |& cmd2

# Convert spaces to underscores in filenames
for name in *\ *; do mv -vn "$name" "${name// /_}"; done

#==============================#
# CMD BASH
#==============================##==============================#

[Ctrl-d] 
# Last one for today. This indicates to the program that there is no more input. In the shell, this usually closes the shell.

[Ctrl-u] 
# Delete everything from the cursor to the beginning of the line. This can also be used to clear a password attempt and start over.

[Ctrl-w] 
# Delete the previous word on the command line (before the cursor). This is highly useful when reusing old commands.

[Ctrl-l] 
# This is usually equivalent to running 'clear'.  Its usually quicker and does not leave the command in your command line history.

[Ctrl-_] 
# Incremental undo of command line edits.

[Meta-#] 
# Comment out the current command from the beginning of the line. Faster than [Ctrl-a] then #.

[Meta-.] 
# Insert the last argument from the previous line in the command history into the current line. This is different from using !$ Press multiple times to keep going back through each history line's last argument.

[Ctrl-e] 
# Move your cursor to the end of the line. Faster than holding down right arrow.

[Ctrl-a] 
# Move your cursor to the beginning of the line. Faster than holding down left arrow. In screen, you need to press <Ctrl-a a>

[Ctrl-q] 
# Sometimes you may find your terminal window appears "frozen". It's not due to the weather. Try pressing Ctrl-q, if that fixes it, its because you hit Ctrl-s. Note: Unfortunately, pressing Ctrl-q multiple times will probably not send you to Hawaii.

[Ctrl-r]string 
# Reverse search through your command history for 'string'. Press Ctrl-r again to continue searching backwards. ESC when done

[C-M]+e 
# That's Ctrl + Meta + e. This will expand any history references you make (like !-5$) so you can check before running.

(xsel -b || pbpaste) |hexdump -c 
# Dump your paste clipboard to hexdump for character by character investigation of what you just copied.

# Option Mnemonics: tar xzvf = Xtract Ze Vucking Files [said in thick German accent]
# Tip: Sometimes you get yourself into weird situations/trapped signals where Ctrl-C and Ctrl-| do not work. Try Ctrl-z and kill %1.

<ctrl-z> bg ; wait %1 ; echo "done" | mail -s "done" [email protected] 
# You started a program, but now want it to notify you when its done.

longcmd ; [Ctrl-Z] ; bg ; disown ; screen ; reptyr $( pidof longcmd ) 
# Suspend and reattach a process to screen.

# Get executed in script its current working directory
CWD=$(cd "$(dirname "$0")" && pwd)
# Explanation: Will return excuting script's current working directory, wherever Bash executes the script containing this line.

PS1="# $PS1" 
# Make your prompt safer with # so that if you accidentally copy & paste it, it does not run. Based on @pacohope's idea.

# An escaped upper case letter typically means the opposite of its lower case counterpart: \D <-> \d, \S <-> \s, etc.

&>
# bash let you use &> to send stdout and stderr to a file. Version 4 or later.

$^
# In bash, $^ expands to 2nd word of previous command

!?foo
# In bash, !?foo will repeat the most recent command that contained the string 'foo'

^foo^bar
# In bash, ^foo^bar repeats the latest command, replacing the first instance of 'foo' with 'bar'

!$
# In bash, !$ expands to last word of previous command

!:n
# Um das nth Argument der Bash (gezählt von 0) zu erhalten

!$ 
# Um das letzte Argument der Bash zu erhalten 

bash -c 'swapoff -a && swapon -a'
# After killing processing using up all your RAM on Linux (Firefox!!), move processes off of swap.

&>
# bash let you use &> to send stdout and stderr to a file. Version 4 or later.

(cmd1;cmd2;cmd3)
# When running commands in a subshell, you can use job control (Ctrl-C, Ctrl-Z, fg, bg) on the subshell as a whole unit.

:(){ :|:& };: 
# DO NOT RUN THIS FORK BOMB

HISTCONTROL="ignoreboth"
# In bash, this sets the history to ignore commands starting with spaces and duplicates. May already be set.

HISTIGNORE="history;ls;date;w;man *"
# In bash, this will leave history, ls, date, w and man whatever out of your command history.

LANG=C sort 
# Setting the LANG=C variable will often fix unexpected problems with sort ignoring symbol characters like +, - and *

> file.txt
# This command flush the contents of a file without the need of removing and creating the same file again. This command is very useful in scripting language when we need an output or log on the same file again and again.

!#
# Where # should be changed with the actual number of the command. For better understanding, see the below example:

!501
# Command of history line 501

# Bash Shell Handy Cheatsheet
#    ^u            Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
#    ^h            Same as backspace
#    ^w            Delete (cut) the word before the cursor (to the clipboard)
#    ^xx           Move between start of command line and current cursor position (and back again)
#    ^t            Swap the last two characters before the cursor
#    ESC-t         Swap the last two words before the cursor
#    Alt/Opt-c     Capitalize the character under the cursor and move to the end of the word.
#    Alt/Opt-l     Lower the case of every character from the cursor to the end of the current word.
#    Alt/Opt-r     Cancel the changes and put back the line as it was in the history (revert).
#    Alt/Opt-t     Swap current word with previous
#    Alt/Opt-u     UPPER capitalize every character from the cursor to the end of the current word.
#    Alt/Opt-Del   Delete the Word before the cursor.
#
#    !abc:p        Print last command starting with abc
#    !$            (Use) Last argument of previous command
#    !$:p          Print out the word that !$ would substitute
#    Alt/Opt-.     (Get) Last argument of previous command
#    !*            (Use) All arguments of previous command
#    ^abc­^­def     Run previous command, replacing abc with def

timeout 1 bash -c '</dev/tcp/216.58.207.46/443 && echo Port is open || echo Port is closed' || echo Connection timeout
# How to test a TCP (or UDP) remote port without telnet or netcat (in a one-liner): (google’s IP and TCP to 443) 

helpful_bash_commands.txt

## BASH ##
	ctrl-r searches your command history as you type
	!!:n 	# selects the nth argument of the last command, and 
	!$ 	# the last arg 
			ls file1 file2 file3; cat !!:1-2  	# shows all files and cats only 1 and 2
	shopt -s cdspell 									# automatically fixes your 'cd folder' spelling mistakes
	set editing-mode vi 								# in your ~/.inputrc to use the vi keybindings for bash and all readline-enabled applications (python, mysql, etc)
		command < file.in   with command <<< "some input text"
		# Input from the commandline as if it were a file by replacing 
		^ 								# is a sed-like operator to replace chars from last command 'ls docs; ^docs^web^' is equal to 'ls web'. The second argument can be empty.
		nohup ./long_script & 	# to leave stuff in background even if you logout
		cd - 							# change to the previous directory you were working on
		ctrl-x ctrl-e 				# opens an editor to work with long or complex command lines

## PSEUDO ALIASES FOR COMMONLY USED LONG COMMANDS
		function lt() { ls -ltrsa "$@" | tail; }
		function psgrep() { ps axuf | grep -v grep | grep "$@" -i --color=auto; }
		function fname() { find . -iname "*$@*"; }
		function remove_lines_from() { grep -F -x -v -f $2 $1; } # removes lines from $1 if they appear in $2
		function mcd() { mkdir $1 && cd $1; }
		alias pp="ps axuf | pager"
		alias sum="xargs | tr ' ' '+' | bc" 							# Usage: echo 1 2 3 | sum

## VIM
		':set spell' 	# activates vim spellchecker. 
		']s' and '[s' 	# to move between mistakes 
		'zg' 				# adds to the dictionary 
		'z=' 				# suggests correctly spelled words
							# check my .vimrc http://tiny.cc/qxzktw and here http://tiny.cc/kzzktw for more

## TOOLS
	-> htop instead of top
	-> ranger is a nice console file manager for vi fans
	-> Google 'magic sysrq' to bring a Linux machine back from the dead
	-> trash-cli sends files to the trash instead of deleting them forever. 
			Be very careful with 'rm' or maybe make a wrapper to avoid deleting '*' by accident (e.g. you want to type 'rm tmp*' but type 'rm tmp *')

	chmod o+x * -R 
		# Never run capitalize the X to avoid executable files. 

	find . -type d -exec chmod g+x {} \;
		 # If you want _only_ executable folders: 
 
	ls *.png | parallel -j4 convert {} {.}.jpg
		# run jobs in parallel easily
		

	apt-file 		# to see which package provides that file you are missing
	dict				# is a commandline dictionary

		sort | uniq 									# to check for duplicate lines
		echo start_backup.sh | at midnight		# starts a command at the specified time

		diff --side-by-side fileA.txt fileB.txt | pager # to see a nice diff

## NETWORKING
	# Read on 'ssh-agent' to strenghten your ssh connections using private keys, while avoiding typing passwords every time you ssh.
	# Use this trick on .ssh/config to directly access 'host2' which is on a private network, and must be accessed by ssh-ing into 'host1' first Host host2
     ProxyCommand ssh -T host1 'nc %h %p'
  	  HostName host2

tar cz folder/ | ssh server "tar xz" 
	# Pipe a compressed file over ssh to avoid creating large temporary .tgz files or even better, use 'rsync'

	# ssmtp can use a Gmail account as SMTP and send emails from the command line. 
		echo "Hello, User!" | mail [email protected] 
		Configure your /etc/ssmtp/ssmtp.conf:
				root=***E-MAIL***
				mailhub=smtp.gmail.com:587
				rewriteDomain=
				hostname=smtp.gmail.com:587
				UseSTARTTLS=YES
				UseTLS=YES
				AuthUser=***E-MAIL***
				AuthPass=***PASSWORD***
				AuthMethod=LOGIN
				FromLineOverride=YES

                                     -~-

		If you use 'sshfs_mount' and suffer from disconnects, use '-o reconnect,workaround=truncate:rename'
		python -m SimpleHTTPServer 8080 or python3 -mhttp.server localhost 8080 		# shares all the files in the current folder over HTTP. 
		socat TCP4-LISTEN:1234,fork TCP4:192.168.1.1:22 		# forwards your port 1234 to another machine's port 22. Very useful for quick NAT redirection.
		# Some tools to monitor network connections and bandwith: 
			lsof -i monitors network connections in real time 
			iftop shows bandwith usage per *connection* 
			nethogs shows the bandwith usage per *process*
		ssh -R 12345:localhost:22 server.com "sleep 1000; exit" # forwards server.com's port 12345 to your local ssh port, even if you machine  is not externally visible on the net. Now you can 
		ssh localhost -p 12345 # from server.com and you will log into your machine. 'sleep' avoids getting kicked out from server.com for inactivity

# Silently Execute a Shell Script that runs in the background and won't die on HUP/logout
(nohup your-command your-args &>/dev/null &)

# Make your prompt a bit safer with a # prefix so that if you accidentally copy & paste it, at least some lines won't execute.
PS1="# $PS1" 

# Setting the LANG=C variable will often fix unexpected problems with sort ignoring symbol characters like +, - and * or just general weirdness. For instance, I just ran into problems because my LANG was set to en_US.UTF-8.
LANG=C sort 

[ $(( $RANDOM % 2 )) -eq 0 ] && command 
# Run a command unreliably. In other worse, it will run sometimes. Could be useful in cron, but remember to use \% instead of % if using in crontab.

PATH=$PATH:/root 
# Put this in your normal user shell profile and freak out the sysadmin. 

$EDITOR 
# On hosts with access by others, you may wish to keep the file you are working on out of the process table for privacy or even security reasons. In which case you can start the editor first and then open the file from within.

PS1="\t $PS1"  
# Customized your shell prompt in BASH so that it is prefixed with the current time.

stty -echo; grep -F -f- passwords.txt; stty echo 
# Use the -f option with - to read search patterns from stdin. Press [Ctrl-d] twice when done. I used -F here for fixed string to avoid things like . matching all. I do all this to avoid passwords in the process table or history.

# Escape spaces in string
FILE_PATH=$( echo "$FILE_PATH" | sed 's/ /\\ /g' )

# Bash command to get current directory
VAR_NAME=$(pwd)

# COLORS
##############################################
# Black        0;30     Dark Gray     1;30
# Blue         0;34     Light Blue    1;34
# Green        0;32     Light Green   1;32
# Cyan         0;36     Light Cyan    1;36
# Red          0;31     Light Red     1;31
# Purple       0;35     Light Purple  1;35
# Brown/Orange 0;33     Yellow        1;33
# Light Gray   0;37     White         1;37
##############################################

# Set a colorful bash prompt per dev test prod environments
PS1='\[\e[1;31m\][\u@\h \W]\$\[\e[0m\] '
# Explanation: It is useful to set a different color for the shell prompt in different deployment environments like dev/test/production, so that you do not mix up your multiple windows and do something by accident in the wrong window.
        # PS1 contains the format of the primary prompt
        # \[\e[1;31m\] sets the foreground color to red
        # \u will be substituted with the current username
        # \h will be substituted with the hostname
        # \W will be substituted with the current directory name
        # \[\e[0m\] is the end marker of the color setting
	 # To make the color stand out even more for root users, the inverse color can be interesting too:
	 # PS1='\[\e[7;31m\][\u@\h \W]\$\[\e[0m\] '
# Other color examples:
	# PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] ' # green
	# PS1='\[\e[1;33m\][\u@\h \W]\$\[\e[0m\] ' # yellow
	# PS1='\[\e[1;34m\][\u@\h \W]\$\[\e[0m\] ' # blue
# You can learn more in man bash, search for "PROMPTING".
# Limitations: Your terminal program must support colors, of course ;-)

# A one liner to test, getting the contents of the current working directory:
select file in *; do filename="$file"; done; echo you selected $filename

# Tales from malicious scripts.
cd /tmp || cd /var/run || cd /mnt || cd /root || cd / || echo "dude your server is really screwed up, I'm outta here." || exit 

# Redirect the output of multiple commands
{ cmd1 ; cmd2 ; cmd3 ; } > out.out 2> err.out
# Explanation: 
    # Curly braces are very helpful for grouping several commands together
    # Be careful with the syntax: 1. there must be whitespace after the opening brace 2. there must be a semicolon after the last command and before the closing brace
    # Another practical use case: test something || { echo message; exit 1; }

#==============================##==============================#
# CMD bash						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

2 - 🖥️cpp

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the cpp command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#   ██████╗██████╗ ██████╗ 
#  ██╔════╝██╔══██╗██╔══██╗
#  ██║     ██████╔╝██████╔╝
#  ██║     ██╔═══╝ ██╔═══╝ 
#  ╚██████╗██║     ██║     
#   ╚═════╝╚═╝     ╚═╝     

# C++
# 
# C++ is an object-oriented programming language which provides facilities for low-level memory manipulation.
# It is widely used by big tech companies, such as, Amazon, Facebook, Google, and SpaceX
#
# To Compile: g++ my_script.cpp
# To Execute: ./a.out
#
# See also 
#   C++ language cheat sheet at /c++/
#   list of pages:      /c++/:list
#   learn C++:          /c++/:learn
#   C++ one-liners:     /c++/:1line
#   C++ weirdness:      /c++/weirdness 
#   search in pages:    /c++/~keyword
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

3 - 🖥️erl

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the erl command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ███████╗██████╗ ██╗     
#  ██╔════╝██╔══██╗██║     
#  █████╗  ██████╔╝██║     
#  ██╔══╝  ██╔══██╗██║     
#  ███████╗██║  ██║███████╗
#  ╚══════╝╚═╝  ╚═╝╚══════╝

# erl
#
# Start Erlang runtime system

# Execute compiled BEAM file (helloworld.beam)
erl -noshell -s helloworld start -s init stop

# Run code from the command line
erl -noshell -eval 'io:fwrite("Hello, World!\n"), init:stop().'
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

4 - 🖥️erlang

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the erlang command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ███████╗██████╗ ██╗      █████╗ ███╗   ██╗ ██████╗ 
#  ██╔════╝██╔══██╗██║     ██╔══██╗████╗  ██║██╔════╝ 
#  █████╗  ██████╔╝██║     ███████║██╔██╗ ██║██║  ███╗
#  ██╔══╝  ██╔══██╗██║     ██╔══██║██║╚██╗██║██║   ██║
#  ███████╗██║  ██║███████╗██║  ██║██║ ╚████║╚██████╔╝
#  ╚══════╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═══╝ ╚═════╝ 

# Erlang
# General-purpose, concurrent, functional programming language, as well as a garbage-collected runtime system.

# See also:
#   erl
#   Erlang language cheat sheets at /erlang/
#   list of pages:      /erlang/:list
#   search in pages:    /erlang/~keyword
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

5 - 🖥️gawk

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the gawk command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#   ██████╗  █████╗ ██╗    ██╗██╗  ██╗
#  ██╔════╝ ██╔══██╗██║    ██║██║ ██╔╝
#  ██║  ███╗███████║██║ █╗ ██║█████╔╝ 
#  ██║   ██║██╔══██║██║███╗██║██╔═██╗ 
#  ╚██████╔╝██║  ██║╚███╔███╔╝██║  ██╗
#   ╚═════╝ ╚═╝  ╚═╝ ╚══╝╚══╝ ╚═╝  ╚═╝

# Strings bearbeiten mit (g)awk
#-----------------------------------------------------------------------///
# In Skripten muss ich gelegentlich Ausgaben von Befehlen formatieren oder sonstwie bearbeiten, um sie z.B. als Mailtext eines Cronjobs zu verwenden.

uname -n | gawk '{print toupper($0)}'
# Das gibt den Hostnamen in Großbuchstaben aus.

# Natürlich geht auch das Umwandeln in Kleinbuchstaben:
echo ASDFGH | gawk '{print tolower($0)}' # Ergebnis: asdfgh

# Vielleicht will ich aber einfach nur wissen, wie lang eine Variable (ein String) ist.
echo "dasisteinlangerstring" | gawk '{print length($0)}' # Ergebnis: 21

# Gelegentlich bräuchte ich eine hexadezimale Zahl als dezimale.
echo 0xAF5D1 | gawk '{print strtonum($0)}' # Ergebnis: 718289
# Wichtig bei strtonum ist, dass es Großbuchstaben sein müssen. Das kann ich ja mit toupper zuvor noch machen.

# ...Das ist ja recht schön, aber wie kann ich eine Shellvariable an gawk übergeben?
String=23halloo1asdfasdf; gawk 'BEGIN {print substr("'"${String}"'",3,5)}' # Ergebnis: hallo

# Wenn wir schon bei substring sind, ist der Weg zu split nicht weit:
String=vorneundhinten; echo | gawk '{split("'"${String}"'",arr,"und"); print arr[1]}' # Ergebnis: vorne
# Das leere "echo" bewirkt das selbe wie "BEGIN" Gawk nimmt es mit Arrays zwar genauer als die Bash, aus irgendwelchen Gründen scheint der Zähler aber bei 1 zu beginnen und nicht bei 0.

# Üblicherweise mache ich mit gawk aber viel einfachere Dinge.
cat /etc/passwd | gawk -F":" '{print $1,$NF}'
# Das zeigt mir alle Linuxuser und ihre Shell, eben das erste und das letzte Feld in der passwd. Der Vorteil von gawk gegenüber cut ist, dass der Feldtrenner aus mehreren Zeichen bestehen kann.

# Als simples Beispiel nehme ich mal Folgendes:
echo -e "eins und zwei\ndrei und vier\nfuenf und sechs"

        # Das ergibt:
        # eins und zwei
        # drei und vier
        # fuenf und sechs
        
echo -e "eins und zwei\ndrei und vier\nfuenf und sechs" | gawk -F" und " '{print $1$2}'

        # Gawk macht dann daraus:
        # einszwei
        # dreivier
        # fuenfsechs
        # Der Feldtrenner ist in diesem Fall das "und" mit je einem Leerzeichen davor und danach.
        

gawk '{a[$2]++;} ENDFILE {c=0; for (keys in a) { c++;};print c}' 2018* 
# Count of total unique column 2 elements seen so far after each file
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

6 - 🖥️gcc

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the gcc command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                 ██████╗  ██████╗ ██████╗
#                ██╔════╝ ██╔════╝██╔════╝
#                ██║  ███╗██║     ██║     
#                ██║   ██║██║     ██║     
#                ╚██████╔╝╚██████╗╚██████╗
#                 ╚═════╝  ╚═════╝ ╚═════╝

                                        
# Compile a file
gcc file.c

# Compile a file with a custom output
gcc -o file file.c

# Debug symbols
gcc -g

# Debug with all symbols.
gcc -ggdb3

# Build for 64 bytes
gcc -m64

# Include the directory {/usr/include/myPersonnal/lib/} to the list of path for #include <....>
# With this option, no warning / error will be reported for the files in {/usr/include/myPersonnal/lib/}
gcc -isystem /usr/include/myPersonnal/lib/

# Build a GUI for windows (Mingw) (Will disable the term/console)
gcc -mwindows

	
# Check if a text snippet is valid C code
gcc -fsyntax-only -xc - <<< "text snippet"

#==============================##==============================#
# CMD gcc						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

7 - 🖥️gdb

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the gdb command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                 ██████╗ ██████╗ ██████╗ 
#                ██╔════╝ ██╔══██╗██╔══██╗
#                ██║  ███╗██║  ██║██████╔╝
#                ██║   ██║██║  ██║██╔══██╗
#                ╚██████╔╝██████╔╝██████╔╝
#                 ╚═════╝ ╚═════╝ ╚═════╝ 
                                         
                                         
                                         
# start the debugger
gdb your-executable

# set a breakpoint
b some-method, break some-method

# run the program
r, run

# when a breakpoint was reached:

# run the current line, stepping over any invocations
n, next
# run the current line, stepping into any invocations
s, step
# print a stacktrace
bt, backtrace
# evaluate an expression and print the result
p length=strlen(string)
# list surrounding source code
l, list
# continue execution
c, continue

# exit gdb (after program terminated)
q, quit

#==============================##==============================#
# CMD GDB						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

8 - 🖥️go

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the go command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#   ██████╗  ██████╗ 
#  ██╔════╝ ██╔═══██╗
#  ██║  ███╗██║   ██║
#  ██║   ██║██║   ██║
#  ╚██████╔╝╚██████╔╝
#   ╚═════╝  ╚═════╝ 

# Go is a free and open source programming language created at Google
# and go is a tool for managing go source code.

# Download and install a package, specified by its import path:
go get package_path

# Compile and run a source file (it has to contain a main package):
go run file.go

# Compile the package present in the current directory:
go build

# Execute all test cases of the current package (files have to end with _test.go):
go test

# Compile and install the current package:
go install

# See also:
#   Go language cheat sheets at /go/
#   list of pages:      /go/:list
#   learn go:       	/go/:learn
#   search in pages:    /go/~keyword
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

9 - 🖥️js

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the js command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#       ██╗███████╗
#       ██║██╔════╝
#       ██║███████╗
#  ██   ██║╚════██║
#  ╚█████╔╝███████║
#   ╚════╝ ╚══════╝

# js
#
# JavaScript often abbreviated as "JS", is a high-level, dynamic, untyped, interpreted run-time language.
# It has been standardized in the ECMAScript language specification.
#
# js is a JavaScript shell, part of SpiderMonkey
# to install spidermonkey: (in Debian) apt-get install libmozjs-24-bin

# Run the shell in interactive mode
js

# Run the JavaScript code in the file hello.js
js hello.js

# Run hello.js then drop into the interactive shell
js -f hello.js -i

# See also:
#   JavaScript language cheat sheets at /js/
#   list of pages:      /js/:list
#   learn JavaScript:   /js/:learn
#   JS one-liners:      /js/1line
#   JS weirdness:       /js/weirdness
#   search in pages:    /js/~keyword
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

10 - 🖥️jshint

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the jshint command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#       ██╗███████╗██╗  ██╗██╗███╗   ██╗████████╗
#       ██║██╔════╝██║  ██║██║████╗  ██║╚══██╔══╝
#       ██║███████╗███████║██║██╔██╗ ██║   ██║   
#  ██   ██║╚════██║██╔══██║██║██║╚██╗██║   ██║   
#  ╚█████╔╝███████║██║  ██║██║██║ ╚████║   ██║   
#   ╚════╝ ╚══════╝╚═╝  ╚═╝╚═╝╚═╝  ╚═══╝   ╚═╝   

# jshint
# 
# JSHint is a fork of JSLint. The reasons for the fork is basically that 
# the author disagrees in some points with Douglas Crockford on JavaScript coding style.
#
# If you're looking for a very high standard for yourself or team, JSLint (by Doug Crockford)
# If you want to be a bit more flexible,
# or have some old pros on your team that don't buy into JSLint's opinions, try JSHint

# to install jshint
sudo npm install jshint -g

# lint all the JavaScript files in the current directory:
find . -name '*.js' -print0 | xargs -0 jshint

# lint all the JavaScript files in a targeted directory:
find ./public/javascripts/ -name '*.js' -print0 | xargs -0 jshint

# Parameter-less options passed to jslint are all set to true by default,
# if you want to set it false, just specify 'false' after the option
jshint --bitwise false hello.js
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

11 - 🖥️jslint

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the jslint command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#       ██╗███████╗██╗     ██╗███╗   ██╗████████╗
#       ██║██╔════╝██║     ██║████╗  ██║╚══██╔══╝
#       ██║███████╗██║     ██║██╔██╗ ██║   ██║   
#  ██   ██║╚════██║██║     ██║██║╚██╗██║   ██║   
#  ╚█████╔╝███████║███████╗██║██║ ╚████║   ██║   
#   ╚════╝ ╚══════╝╚══════╝╚═╝╚═╝  ╚═══╝   ╚═╝   

# jslint
# 
# The JavaScript Code Quality Tool written by Dougls Crockford

# to install jslint
sudo npm install jslint -g

# lint all the JavaScript files in the current directory:
find . -name '*.js' -print0 | xargs -0 jslint

# lint all the JavaScript files in a targeted directory:
find ./public/javascripts/ -name '*.js' -print0 | xargs -0 jslint

# Parameter-less options passed to jslint are all set to true by default,
# if you want to set it false, just specify 'false' after the option
jslint --bitwise false hello.js
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

12 - 🖥️julia

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the julia command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#       ██╗██╗   ██╗██╗     ██╗ █████╗ 
#       ██║██║   ██║██║     ██║██╔══██╗
#       ██║██║   ██║██║     ██║███████║
#  ██   ██║██║   ██║██║     ██║██╔══██║
#  ╚█████╔╝╚██████╔╝███████╗██║██║  ██║
#   ╚════╝  ╚═════╝ ╚══════╝╚═╝╚═╝  ╚═╝

# Julia 
# high-level dynamic programming language designed to address the needs of high-performance numerical analysis
# and computational science while also being effective for general-purpose programming

# Execute script from the file; pass additional arguments
julia script.jl arg1 arg2

# Execute command like arguments like script
julia -e 'for x in ARGS; println(x); end' foo bar

# See also:
#   Julia language cheat sheets at /julia/
#   list of pages:      /julia/:list
#   learn julia:        /julia/:learn
#   search in pages:    /julia/~keyword
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

13 - 🖥️lua

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the lua command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ██╗     ██╗   ██╗ █████╗ 
#  ██║     ██║   ██║██╔══██╗
#  ██║     ██║   ██║███████║
#  ██║     ██║   ██║██╔══██║
#  ███████╗╚██████╔╝██║  ██║
#  ╚══════╝ ╚═════╝ ╚═╝  ╚═╝

# lua
# A powerful, light-weight embeddable programming language.

# Start an interactive Lua shell:
lua

# Execute a Lua script:
lua script_name.lua --optional-argument

# Execute a Lua expression:
lua -e 'print( "Hello World" )'

# All options are handled in order, except -i. For instance, an invocation like
# first set a to 1, then print the value of a (1), and finally run the file script.lua
lua -e'a=1' -e 'print(a)' script.lua

# See also:
#   Lua language cheat sheets at /lua/
#   list of pages:      /lua/:list
#   learn lua:          /lua/:learn
#   search in pages:    /lua/~keyword
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

14 - 🖥️luarocks

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the luarocks command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ██╗     ██╗   ██╗ █████╗ ██████╗  ██████╗  ██████╗██╗  ██╗███████╗
#  ██║     ██║   ██║██╔══██╗██╔══██╗██╔═══██╗██╔════╝██║ ██╔╝██╔════╝
#  ██║     ██║   ██║███████║██████╔╝██║   ██║██║     █████╔╝ ███████╗
#  ██║     ██║   ██║██╔══██║██╔══██╗██║   ██║██║     ██╔═██╗ ╚════██║
#  ███████╗╚██████╔╝██║  ██║██║  ██║╚██████╔╝╚██████╗██║  ██╗███████║
#  ╚══════╝ ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝  ╚═════╝╚═╝  ╚═╝╚══════╝

# LuaRocks is the package manager for Lua modules

# install luarocks
wget https://luarocks.org/releases/luarocks-2.4.1.tar.gz
tar zxpf luarocks-2.4.1.tar.gz
cd luarocks-2.4.1
./configure; sudo make bootstrap

# install lua package
luarocks install luasocket

# search for lua package
luarocks search luasec
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

15 - 🖥️make

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the make command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███╗   ███╗ █████╗ ██╗  ██╗███████╗
#                ████╗ ████║██╔══██╗██║ ██╔╝██╔════╝
#                ██╔████╔██║███████║█████╔╝ █████╗  
#                ██║╚██╔╝██║██╔══██║██╔═██╗ ██╔══╝  
#                ██║ ╚═╝ ██║██║  ██║██║  ██╗███████╗
#                ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝
                

                                                  
make ; mpg123 hawaii-five-o-theme.mp3
# Play a song at the end of long running command to notify you. 

#==============================##==============================#
# CMD MAKE						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

16 - 🖥️perl

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the perl command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ███████╗██████╗ ██╗     
#                ██╔══██╗██╔════╝██╔══██╗██║     
#                ██████╔╝█████╗  ██████╔╝██║     
#                ██╔═══╝ ██╔══╝  ██╔══██╗██║     
#                ██║     ███████╗██║  ██║███████╗
#                ╚═╝     ╚══════╝╚═╝  ╚═╝╚══════╝
                

# The Perl 5 language interpreter.

# Parse and execute a Perl script:
perl script.pl

# Check syntax errors on a Perl script:
perl -c script.pl

# Parse and execute a perl statement:
perl -e perl_statement

# Import module before execution of a perl statement:
perl -Mmodule -e perl_statement

# Run a Perl script in debug mode, using perldebug:
perl -d script.pl

# Loo[p] over all lines of a file, editing them [i]n-place using a find/replace [e]xpression:
perl -p -i -e 's/find/replace/g' filename

# Run a find/replace expression on a file, saving the original file with a given extension:
perl -p -i'.old' -e 's/find/replace/g' filename

# See also:
#   Perl language cheat sheets at /perl/
#   list of pages:      /perl/:list
#   learn perl:         /perl/:learn
#   perl one-liners:    /perl/1line
#   search in pages:    /perl/~keyword
                                                
                                              
#==============================#
# CMD PERL
#==============================##==============================#
perl -pi.backup -e 's/\r//' foo.txt
#

perl -e 'sub a{@_[1-1]-@_[2-1]};\>print a(1-1,2-1)'
#

perl -e "s/^(\s*S[\s\S]*?)(\/\/\s*.*)$/\n\/\2\n\1" -p a.c>b.c
#

perl -wnle "/RE/ and print" filename
# Use Perl to grep for a regex RE

# The good: Many functions take regex arguments
# The bad: Limited features compared to PCRE
# The ugly: \|, \(, \), \{, \}

# Summarizing ed(1) movement commands
	{n} line #n
	+{n} n lines down
	-{n} n lines up
	/ search fwd
	? search back
	'a go to mark 'a

/(Ch|H|Kh)ann?[aeiu]kk?ah?/
# Regular expression for various spellings of Hanukkah 

perl -MMIME::Base64 -e 'print encode_base64("john\0john\0passwd")';
am9obgBqb2huAHBhc3N3ZA==

#=======================================================================================================
# 1. PERL ONE-LINERS
#=======================================================================================================

grep -in WORD FILE* | perl -ne 'if (/(.*):(\d*):\s*(.*)\s*/) { print $1, " " x (20 - length $1), " ", "0" x (5 - length $2), $2, "   $3\n"}'
# Display Table of WORD in FILE* - Displays all occurrences of WORD in the FILE*(s), formatting as a table with filename, line number and line text. - Simple example for short filenames.  Seems to cause trouble in Windows command line

egrep -in '(Alabama|"AL")' *.asp | perl -ne 'if (/(.*):(\d*):\s*(.*)\s*/) { print $1, " " x (50 - length $1), " ", "0" x (5 - length $2), $2, "   $3\n"}'
# Display Table of WORD in FILE* - Displays all occurrences of WORD in the FILE*(s), formatting as a table with filename, line number and line text. - More complex example using egrep and assuming longer filenames (note the '50' in the spaces computation) - Also seems to cause trouble in Windows command line.

# Text Trimming and Processing
#-----------------------------------------------------------------------

cat myfile | perl -ne 'if (/^\s*(.*?)\s*$/s) { print "${1}\n" }' 
# Trim excess blanks from beginning to end of line. A Cygwin creature. - seems less efficient in practice

perl -ne 'if (/^\s*(.*?)\s*$/s) { print "${1}\n" }' < temp.txt
# Trim excess blanks from beginning to end of line. - Don't forget the tr command! Not that we have use right now...

# Infinite "music"
perl -e 'use bytes; for($t=0;;$t++){ print chr($t*(($t>>13|$t>>8)&30&$t>>4)); }' | play -t raw -b8 -r8k -e un - vol 0.5

# File/Directory one liners
#-----------------------------------------------------------------------
ls -R					
# Recursively list contents of subdirectories

ls -lAF | perl -e 'while (<>) { next if /^dt/; $sum += (split)[4] } print "$sum\n"'
# Find the sum of the sizes of the non-directory files in a directory

ls | xargs perl -e '@ARGV = grep( -d $_ , @ARGV); print "@ARGV\n"'	
# Different formats for the subdirectories of just this directory

ls | xargs perl -e '@ARGV = grep( -d $_ , @ARGV); while($dir = shift @ARGV) { print "$dir\n" }'
# Different formats for the subdirectories of just this directory

# Path Parsing One Liners
#=======================================================================================================
# Can't use EXPR because it only matches at the beginning of a line.
if echo $PATH | grep -q "Program" ; then echo "present"; else echo "absent"; fi
if echo $PATH | grep -q "\." ; then echo ". present"; else export PATH=".:$PATH"; echo "added . to path";  fi
perl -e "print \"$PATH\" =~ /Program/"	# not good for testing

if [ "$fram" ]; then echo "found a fram"; else echo "no fram here"; fi
# See if a variable exists

perl -e "print join qq(\n), split /;/, '%CLASSPATH%' "
# Use Perl to do the same thing - to print all the variable names on one line - note this can futz up some pathnames

perl -e "foreach (split ';', '%CLASSPATH%') { print; print qq(\n) }"
# Use Perl to do the same thing - to print all the variable names on one line - note this can futz up some pathnames

perl -e 'use bytes; for($t=0;;$t++){ print chr($t*(($t>>13|$t>>8)&30&$t>>4)); }' | play -t raw -b8 -r8k -e un - vol 0.5 
# Infinite "music"

perl -ne 'print if /start_pattern/../stop_pattern/' file.txt
# Display a block of text: multi-line grep with perl
# 		-n reads input, line by line, in a loop sending to $_ Equivalent to while () { mycode } 
# 		-e execute the following quoted string (i.e. do the following on the same line as the perl command) the elipses .. operator behaves like a range, remembering the state from line to line.

#=======================================================================================================
# DOS Fu One Liners
#=======================================================================================================
for /F %i IN (lines.txt) DO echo %i
# DOS/Windows Equivalents of Common UNIX Commands - Iterate through all the lines in a file, doing something

prompt $P $C$D$T$F: $_$+$G$S
# DOS/Windows Prompt

perl -e '$n=0;@a=(a..z,A..Z,0..9," ","!");$A=2**6;$H="3300151524624962270817190703002462370017172463";while($n<length $H){$M.=$a[substr($H,$n,2)];$n+=2};$M=~s/X/${A}th/;print "$M\n"'

perl -e '$n=0;@TimToady=(a..z,A..Z,0..9," ","!");$A=2**6;$H="3300151524624962270817190703002462370017172463";while($n<length $H){$M.=$TimToady[substr($H,$n,2)];$n+=2};$M=~s/X/${A}th/;print "$M\n"' # Thought of a better way to do this in this medium.

# Rename all files in the current directory by capitalizing the first letter of every word in the filenames
ls | perl -ne 'chomp; $f=$_; tr/A-Z/a-z/; s/(?<![.'"'"'])\b\w/\u$&/g; print qq{mv "$f" "$_"\n}'
# Explanation: 
    # When you pipe something to perl -ne, each input line is substituted into the $_ variable. The chomp, tr///, s/// perl functions in the above command all operate on the $_ variable by default.
    # The tr/A-Z/a-z/ will convert all letters to lowercase.
    # The regular expression pattern (?<![.'])\b\w matches any word character that follows a non-word character except a dot or a single quote.
    # The messy-looking '"'"' in the middle of the regex pattern is not a typo, but necessary for inserting a single quote into the pattern. (The first single quote # closes the single quote that started the perl command, followed by a single quote enclosed within double quotes, followed by another single quote to continue the perl command.) We could have used double quotes to enclose the perl command, but then we would have to escape all the dollar signs which would make everything less readable.
    # In the replacement string $& is the letter that was matched, and by putting \u in front it will be converted to uppercase.
    # qq{} in perl works like double quotes, and can make things easier to read, like in this case above when we want to include double quotes within the string to be quoted.
    # After the conversions we print a correctly escaped mv command. Pipe this to bash to really execute the rename with | sh.
# Limitations: The above command will not work for files with double quotes in the name, and possibly other corner cases.

# Generate a sequence of numbers
perl -e 'print "$_\n" for (1..10);'
# Explanation: Print the number with newline character which could be replaced by any char.

    
   

# Shuffle lines
... | perl -MList::Util=shuffle -e 'print shuffle <>;'

# Explanation: Sorting lines is easy: everybody knows the sort command. But what if you want to do the other way around? The above perl one-liner does just that:
    # -MList::Util=shuffle load the shuffle function from the List::Util package
    # -e '...' execute Perl command
    # print shuffle <> call List::Util::shuffle for the lines coming from standard input, read by <>

## Related one-liners

# Shuffle lines
... | perl -MList::Util -e 'print List::Util::shuffle <>'

# Explanation: Sorting lines is easy: everybody knows the sort command. But what if you want to do the other way around? The above perl one-liner does just that:
    # -MList::Util load the List::Util module (as if doing use List::Util inside a Perl script)
    # -e '...' execute Perl command
    # print List::Util::shuffle <> call List::Util::shuffle for the lines coming from standard input, read by <>
# Another way would be sort -R if your version supports that (GNU, as opposed to BSD). In BSD systems you can install coreutils and try gsort -R instead. (For eample on OSX, using MacPorts: sudo port install coreutils.)

# Group count sort a log file
A=$(FILE=/var/log/myfile.log; cat $FILE | perl -p -e 's/.*,([A-Z]+)[\:\+].*/$1/g' | sort -u | while read LINE; do grep "$LINE" $FILE | wc -l | perl -p -e 's/[^0-9]+//g'; echo -e "\t$LINE"; done;);echo "$A"|sort -nr
# Explanation: 
    # SQL: SELECT COUNT(x), x FROM y GROUP BY x ORDER BY count DESC;
    # BASH: a temp var for the last sort: $A=$(the file you want: FILE=/var/log/myfile.log
    # dump the file to a stream: cat $FILE |
    # cut out the bits you want to count: perl -p -e 's/.*,([A-Z]+)[\:\+].*/$1/g' |
    # get a unique list: sort -u |
    # for each line/value in the stream do stuff: while read LINE; do
    # dump all lines matching the current value to an inner stream: grep "$LINE" $FILE |
    # count them: wc -l |
    # clean up the output of wc and drop the value on stdout: perl -p -e 's/[^0-9]+//g';
    # drop the current value to stdout: echo -e "\t$LINE";
    # finish per value operations on the outer stream: done;
    # finish output to the temp var: );
    # dump the temp var to a pipe: echo "$A" |
    # sort the list numerically in reverse: sort -nr

# Explanation: Knowing the octal, hexadecimal or decimal code of the ASCII character set can be handy at times. In the past, too often I did things like:
perl -e 'for my $n (1 .. 255) { print $n, chr($n), $n, "\n"; }'
	# ... when a simple man ascii would have done the trick...
	# On a related note, these all print the letter "A":
        # echo -e '\0101'
        # printf '\101'
        # printf '\x41'
        # perl -e 'print "\x41"'

# Calculate an h index from an EndNote export
MAX=$(NUM=1;cat author.xml |perl -p -e 's/(Times Cited)/\n$1/g'|grep "Times Cited" |perl -p -e 's/^Times Cited:([0-9]*).*$/$1/g'|sort -nr | while read LINE; do if [ $LINE -ge $NUM ]; then echo "$NUM"; fi; NUM=$[$NUM+1]; done;); echo "$MAX"|tail -1
        # Explanation: EndNote?! I know but sometimes we have windows users as friends

# Rename files with numeric padding
perl -e 'for (@ARGV) { $o = $_; s/\d+/sprintf("%04d", $&)/e; print qq{mv "$o" "$_"\n}}'
# Explanation: Basically a one-liner perl script. Specify the files to rename as command line parameters, for example:
perl -e '.....' file1.jpg file2.jpg
# In this example the files will be renamed to file0001.jpg and file0002.jpg, respectively. The script does not actually rename anything. It only prints the shell commands to execute that would perform the renaming. This way you can check first that the script would do, and if you want to actually do it, then pipe the output to sh like this:
perl -e '.....' file1.jpg file2.jpg | sh
# what is happening in the one-liner perl script:
    # for (@ARGV) { ... } is a loop, where each command line argument is substituted into the auto-variable $_.
    # $o = $_ :: save the original filename
    # s/// :: perform pattern matching and replacement on $_
    # print qq{...} :: print the mv command, with correctly quoted arguments
# Limitations: The script does not cover all corner cases. For example it will not work with files that have double-quotes in their names. In any case, it is safe to review the output of the script first before piping it to sh.

# Counting the number of commas in CSV format
perl -ne 'print tr/,//, "\n"' < file.csv | sort -u
# Explanation: Sometimes I need to know if a CSV file has the right number of columns, and how many columns there are. The tr/// operator in perl is normally used to convert a set of characters to another set of characters, but when used in a scalar context like in this example, it returns the number of matches of the specified characters, in this case a comma. The perl command above prints the number of commas in every line of the input file. sort -u sorts this and outputs only the unique lines. If all lines in the CSV file have the same number of commas, there should be one line of output. The number of columns in the file is this number + 1.
# Limitations: This one-liner does not handle the more general case when the columns may have embedded commas within quotes. For that you would need a more sophisticated method. This simple version can still be very useful in many common cases.

Shuffle lines
... | perl -MList::Util -e 'print List::Util::shuffle <>'
# Explanation: Sorting lines is easy: everybody knows the sort command. But what if you want to do the other way around? The above perl one-liner does just that:
        # -MList::Util load the List::Util module (as if doing use List::Util inside a Perl script)
        # -e '...' execute Perl command
        # print List::Util::shuffle <> call List::Util::shuffle for the lines coming from standard input, read by <>
        # Another way would be sort -R if your version supports that (GNU, as opposed to BSD). In BSD systems you can install coreutils and try gsort -R instead. (For eample on OSX, using MacPorts: sudo port install coreutils.)

# Best method to organize massive word lists
# For simple deduplication of arrays you can use an associative array/hash. Simply use the word as the key and give it a value of true.  Enumerating the keys then gives you the deduplicated list of words.  If you want that list sorted then simply sort it afterwards.  Here's a quick Perl example:

#!/usr/bin/perl
use strict;
use warnings;

my %words;

while (my $line = <STDIN>) {
    chomp($line);
    $words{lc($line)} = 1;
}
print join("\n", sort keys %words);

#==============================##==============================#
# CMD PERL
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

17 - 🖥️python

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the python command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ██╗   ██╗████████╗██╗  ██╗ ██████╗ ███╗   ██╗
#                ██╔══██╗╚██╗ ██╔╝╚══██╔══╝██║  ██║██╔═══██╗████╗  ██║
#                ██████╔╝ ╚████╔╝    ██║   ███████║██║   ██║██╔██╗ ██║
#                ██╔═══╝   ╚██╔╝     ██║   ██╔══██║██║   ██║██║╚██╗██║
#                ██║        ██║      ██║   ██║  ██║╚██████╔╝██║ ╚████║
#                ╚═╝        ╚═╝      ╚═╝   ╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═══╝
                

                                                                    
# Desc: Python is a high-level programming language.
# and python is a Python interpreter.

# Basic example of server with python
# Will start a Web Server in the current directory on port 8000
# go to http://127.0.0.1:8000

# Python v2.7
python -m SimpleHTTPServer
# Python 3
python -m http.server 8000

# SMTP-Server for debugging, messages will be discarded, and printed on stdout.
python -m smtpd -n -c DebuggingServer localhost:1025

# Pretty print a json
python -mjson.tool

python -m SimpleHTTPServer 
# Start a web server on port 8000 that uses CWD. See http://bit.ly/CLIhttpd  for other language examples. The command generates a simple web page over HTTP for the directory structure tree and can be accessed at port 8000 in browser till interrupt signal is sent.

python -c "for path in '%CLASSPATH%'.split(';'): print path"
# Use Python to print all the variable names on one line - note this can futz up some pathnames

python -c "import csv,json;print json.dumps(list(csv.reader(open('csv_file.csv'))))"
# Convert CSV to JSON - Replace 'csv_file.csv' with your filename.

echo "$(python -V 2>&1)" > file
or 
python -V 2> file
# Python version to a file
# This command sent the Python version to a file. This is intended to be used in scripts. For some reason, simple redirections didn't work with "python -V" This is sample output 
	cat file
	Python 2.6.3

# Zen of Python
# or just 'import this' in python
python -mthis

# See also:
#   Python language cheat sheets at /python/
#   list of pages:      /python/:list
#   learn python:       /python/:learn
#   search in pages:    /python/~keyword

# Get load average in a more parse-able format
python -c 'import os; print os.getloadavg()[0]'
# Explanation: In short, it runs a Python one-line script which imports the 'os' module and uses it to get the load average. It then indexes into a tuple, using the index of zero. The tuple is like this: (one-minute-average, five-minute-average, fifteen-minute-average), so you could substitute 0 for 1 to get the five minute load average, or 2 to get the fifteen minute load average. I find this really useful when writing larger bash one-liners which require this information, as I do not have to parse the output of uptime.
# Limitations: Requires Python.

# Random 6-digit number
python -c 'import random; print(random.randint(0,1000000-1))'
# Explanation: Stackoverflow has a dozen different ways to generate numbers, all of which fall apart after 3-4 digits. This solution requires Python to be installed, but is simple and direct.
# Limitations: Requires Python, it's not a pure-Bash solution

python -m ensurepip --default-pip && python -m pip install --upgrade pip setuptools wheel
# Bootstrap python-pip & setuptools

#==============================##==============================#
# CMD PYTHON						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

18 - 🖥️python3

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the python3 command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#      ██████╗ ██╗   ██╗████████╗██╗  ██╗ ██████╗ ███╗   ██╗██████╗ 
#      ██╔══██╗╚██╗ ██╔╝╚══██╔══╝██║  ██║██╔═══██╗████╗  ██║╚════██╗
#      ██████╔╝ ╚████╔╝    ██║   ███████║██║   ██║██╔██╗ ██║ █████╔╝
#      ██╔═══╝   ╚██╔╝     ██║   ██╔══██║██║   ██║██║╚██╗██║ ╚═══██╗
#      ██║        ██║      ██║   ██║  ██║╚██████╔╝██║ ╚████║██████╔╝
#      ╚═╝        ╚═╝      ╚═╝   ╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═══╝╚═════╝ 
                                                                            

python3 -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < broken.yaml > fixed.json

python3 -m http.server 80 on

#==============================##==============================#
# CMD bash                                                     #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

19 - 🖥️ruby

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ruby command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ██████╗ ██╗   ██╗██████╗ ██╗   ██╗
#  ██╔══██╗██║   ██║██╔══██╗╚██╗ ██╔╝
#  ██████╔╝██║   ██║██████╔╝ ╚████╔╝ 
#  ██╔══██╗██║   ██║██╔══██╗  ╚██╔╝  
#  ██║  ██║╚██████╔╝██████╔╝   ██║   
#  ╚═╝  ╚═╝ ╚═════╝ ╚═════╝    ╚═╝

# Ruby is a dynamic, reflective, object-oriented, general-purpose programming language
# ruby is a ruby interpreter

# invoke Ruby from the command line to run the script foo.rb
ruby foo.rb

# pass code as an argument
ruby -e 'puts "Hello world"'

# The -n switch acts as though the code you pass to Ruby was wrapped in the following:
# while gets
#  # code here
#  end
ruby -ne 'puts $_' file.txt

# The -p switch acts similarly to -n, in that it loops over each of the lines in the input
# after your code has finished, it always prints the value of $_
# Example: replace e with a
echo "eats, shoots, and leaves" | ruby -pe '$_.gsub!("e", "a")'

# BEGIN block executed before the loop
echo "foo\nbar\nbaz" | ruby -ne 'BEGIN { i = 1 }; puts "#{i} #{$_}"; i += 1'
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

20 - 🖥️rust

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the rust command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ██████╗ ██╗   ██╗███████╗████████╗
#  ██╔══██╗██║   ██║██╔════╝╚══██╔══╝
#  ██████╔╝██║   ██║███████╗   ██║   
#  ██╔══██╗██║   ██║╚════██║   ██║   
#  ██║  ██║╚██████╔╝███████║   ██║   
#  ╚═╝  ╚═╝ ╚═════╝ ╚══════╝   ╚═╝

# Rust is a systems programming language sponsored by Mozilla Research

# See also:
#   rustc
#   Rust language cheat sheets at /rust/
#   list of pages:      /rust/:list
#   search in pages:    /rust/~keyword
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░