Good utilities for extracting stuff from text
A range is two addresses separated by a comma. /pattern1/ , /pattern2/
Can't use alternation with sed but you can with grep
awk will not accept parameters until after it has opened
the input file and that doesn't happen until after the BEGIN block has
finished. If you want to use awk as a calculator with no input file you
can build the command string in advance and then run it with eval:
a=79
b="awk 'BEGIN {print $a / 3}'"
c=$(eval $b)
echo $c --> 26.3333
Bash string extractions and other manipulations
if [[ "$string" =~ $substring ]]; then
String length
${#string}
or
expr length $string
Length of Matching Substring at Beginning of String
expr match "$string" '$substring'
$substring is a regular expression.
Index - Numerical position in $string of first character in $substring that matches.
expr index $string $substring
Substring Extraction - Extracts substring from $string at $position.
${string:position}Extracts $length characters of substring from $string at $position.
${string:position:length}
Extracts $length characters of substring from $string at $position.
Other neat stuff
![]() |
This site best viewed with a browser |
| Warning: This is a Debian centric site | |
| Many thanks to Debra and Ian Murdock for making Debian possible | |
| First created Apr 22, 2008 ~ Last revised January 25, 2010 |