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
GNU Regex POSIX character classes Character classes are a feature introduced in the POSIX standard. A character class is a special notation for describing lists of characters that have a specific attribute, but the actual characters can vary from country to country and/or from character set to character set. For example, the notion of what is an alphabetic character differs between the United States and France. Linux Linux Utilities Bash
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