lang-bash

Bash Manual

$ man -P cat bash NAME bash – GNU Bourne-Again SHell SYNOPSIS bash [options] [command_string | file] COPYRIGHT Bash is Copyright (C) 1989-2018 by the Free Software Foundation, Inc. DESCRIPTION Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file. Bash also incorporates useful features from …

Bash Manual Read More »

Bash: printf

Also see: https://linuxize.com/post/bash-printf-command/ Format Placeholder Syntax Flags Some commonly used: – Left align the printed text within the field. (default: right-aligned) + Prefix the numbers with a + or – signs. (default: no + for positive number).Negative number is always is prefixed with -. 0 Pads numbers with leading zeros rather than space. Also see: https://www.gnu.org/software/libc/manual/html_node/Integer-Conversions.html#Integer-Conversions Specifiers Some commonly …

Bash: printf Read More »

Bash: Split One String Into Multiple Variables

Split “abc-123” into two variables by – Using awk Using cut Using IFS and read Using Shell Parameter Expansion/Substitution See: https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html https://tldp.org/LDP/abs/html/parameter-substitution.html ${var%Pattern} Remove from $var the shortest part of Pattern that matches the back end (right) of $var. ${var%%Pattern} Remove from $var the longest part of Pattern that matches the back end (right) of $var. ${var#Pattern} Remove from $var the shortest part of $Pattern that matches the front end (left) of $var. ${var##Pattern} Remove from $var the longest part of $Pattern that matches the front end (left) of $var.