Webserver in bash - execute bash command Do you want a quick, dirty, and unsafe way to execute commands to your Linux box over HTTP? You can use the following hack! I don't recommend using this for a production system or something more important than a hobby project. Linux Bash
Bash Parameter Substitution Table 1: Bash Parameter Substitution Variable Description ${parameter:-defaultValue} Get default shell variables value ${parameter:=defaultValue} Set default shell variables value ${parameter:?"Error Message"} Display an error message if parameter is not set ${#var} Find the length of the string ${var%pattern} Remove from shortest rear (end) pattern ${var%%pattern} Remove from longest rear (end) pattern ${var:num1:num2} Substring ${var#pattern} Remove from shortest front pattern ${var##pattern} Remove from longest front pattern ${var/pattern/string} Find and replace (only replace first occurrence) ${var//pattern/string} Find and replace all occurrences ${! Linux Bash Development
BASH - Check IP is in range of ip pools I have a list of IPs in MAXCDN_ARRAY to be used as whitelist. I want to check if a specific IP address is in range in this array. How can I structure the code so that it can compare all IPs in the array and say the specific IP in in range of this list or not? GrepCIDR You can use grepcidr to check if an IP address is in a list of CIDR networks. Linux Bash Development
Awk BuiltIn Variables The following is a list of variables that awk sets automatically on certain occasions in order to provide information to your program. The variables that are specific to gawk are marked with a pound sign (#). These variables are gawk extensions. In other awk implementations or if gawk is in compatibility mode (see section Command-Line Options ), they are not special. VARIABLE NAME DESCRIPTION FS input field separator variable OFS Output Field Separator RS Input Record Separator variable ORS Output Record Separator Variable NR Number of Records NF Number of Fields in a record FILENAME Name of the current input file FNR Number of Records relative to the current input file RLENGTH length of the substring matched by the match() function RSTART first position in the string matched by match() function FS - input field separator variable It represents the (input) field separator and its default value is space. Linux Linux Utilities Bash Development
Awk If Statement In this awk tutorial, let us review awk conditional if statements with practical examples. Normally conditional statement checks the condition, before performing any action. If the condition is true action(s) are performed. Similarly action can be performed if the condition is false. Conditional statement starts with the keyword called "if". Awk supports three different kind of if statement. Awk Simple If statement Awk If-Else statement Awk If-Else-If statement awk If Statement Single Action: Simple If statement is used to check the conditions, if the condition returns true, it performs its corresponding action(s). Linux Linux Utilities Bash Development
Bash: if statement A Shell script usually needs to test 'if' a command succeeds or a condition is met. In Bash, this test can be done with a Bash 'if statement'. As with any other programming language, Bash comes with conditional expressions that allow you to test for conditions and alter the control flow if the condition is satisfied or not. Bash Development
Bash: Guide to Bash IFS variable What is IFS The IFS is a special shell variable. The IFS (Internal Field Separator) is used for word splitting after expansion and to split lines into words with the read builtin command . You can change the value of IFS as per your requirments. The default value is <space><tab><newline> You can print it with the following command: cat -etv <<<"$IFS" reset the Bash behavior to its default: unset IFS bash man page The shell treats each character of IFS as a delimiter, and splits the results of the other expansions into words on these characters. Bash Development
Bash: Guide to Bash Arrays The Bash array variables come in two flavors, the one-dimensional indexed arrays, and the associative arrays. The indexed arrays are sometimes called lists and the associative arrays are sometimes called dictionaries or hash tables. The support for Bash Arrays simplifies heavily how you can write your shell scripts to support more complex logic or to safely preserve field separation. This guide covers the standard bash array operations and how to declare (set), append, iterate over (loop), check (test), access (get), and delete (unset) a value in an indexed bash array. Bash Development
Colorize linux programs output Learn how to make your Bash/Shell script colourful and attractive without installing any plugins and configuration. Linux Bash Development
7-bit ASCII Character Codes 7-bit ASCII Character Codes The ASCII table contains letters, numbers, control characters, and other symbols. Each character is assigned a unique 7-bit code. ASCII is an acronym for American Standard Code for Information Interchange. Decimal Octal Hex Binary Value Description Carret notation Escape sequence in C 000 000 00 0000 0000 NUL "null" character ^@ \0 001 001 01 0000 0001 SOH start of header ^A 002 002 02 0000 0010 STX start of text ^B 003 003 03 0000 0011 ETX end of text ^C 004 004 04 0000 0100 EOT end of transmission ^D 005 005 05 0000 0101 ENQ enquiry ^E 006 006 06 0000 0110 ACK acknowledgment ^F 007 007 07 0000 0111 BEL bell ^G \a 008 010 08 0000 1000 BS backspace ^H \b 009 011 09 0000 1001 HT horizontal tab ^I \h 010 012 0A 0000 1010 LF line feed ^J \n 011 013 0B 0000 1011 VT vertical tab ^K \v 012 014 0C 0000 1100 FF form feed ^L \f 013 015 0D 0000 1101 CR carriage return ^M \r 014 016 0E 0000 1110 SO shift out ^N 015 017 0F 0000 1111 SI shift in ^O 016 020 10 0001 0000 DLE data link escape ^P 017 021 11 0001 0001 DC1 device control 1 (XON) ^Q 018 022 12 0001 0010 DC2 device control 2 ^R 019 023 13 0001 0011 DC3 device control 3 (XOFF) ^S 020 024 14 0001 0100 DC4 device control 4 ^T 021 025 15 0001 0101 NAK negative acknowledgement ^U 022 026 16 0001 0110 SYN synchronous idle ^V 023 027 17 0001 0111 ETB end of transmission block ^W 024 030 18 0001 1000 CAN cancel ^X 025 031 19 0001 1001 EM end of medium ^Y 026 032 1A 0001 1010 SUB substitute ^Z 027 033 1B 0001 1011 ESC escape ^[ \e 028 034 1C 0001 1100 FS file separator ^\ 029 035 1D 0001 1101 GS group separator ^] 030 036 1E 0001 1110 RS request to send/record separator ^^ 031 037 1F 0001 1111 US unit separator ^_ 032 040 20 0010 0000 SP space ^? Development Linux Linux Utilities