#!/bin/bash #.Y / 70 83 / / / / 105 / / / / / / ;A4_QUER.Y #.YT 3 2 0 0 3 3 1 / / / #.H!a!0:linux//string_/THIS!0.!c # # copyright : (C) 2009 by Thomas Bruecker =: tbrue # email : public0x05bf@bluewin.ch # # tbrue 21sep2007 # # string_ THIS : string utilities #++++++++++++++++++++++++++++++++ # # MyHash("linux//string_/THIS") = 0x0A6D # # * for every function: # * if returned result is not commented, the function returns 0 on no-error. # # temp: SCRIPTS=root/bin string_dotL() # .L # $1 : string # $2 : field-witdth # print string left-aligned to "stdout". { local Width Width=$2 printf %-${Width}s $1 } string_dotR() # .R # $1 : string # $2 : field-witdth # print string right-aligned to "stdout". { local Width Width=$2 printf %${Width}s $1 } string_2LowCase() # ToLowCase # $1 : string # convert string to low-case and print it to "stdout". { echo "$1" | sed 's/.*/\L&/' } string_MatchQ() # Match? # $1, $2 : strings # * return 0 if $2 is a substring of $1 . # * $2 is treated as regular expression. { echo "$1" | grep -q "$2" return # returns result of "grep ..." } # thats what i want. string_MatchAnyQ() # MatchAny? # $1, $2 : strings; # $2 contains space-separated substrings =: name. (see bash "name".) # * return 0 if any name in $2 is a substring of $1 . # * the names in $2 are treated as regular expressions. { local Name0x0A6D for Name0x0A6D in $2 # no "" around $2 !!! do if string_MatchQ "$1" "$Name0x0A6D" ; then # Match? return 0 fi done # else return 1 } string_Spaces() # $1 : # spaces to print. # print count = $1 spaces '" "' to stdout. { local I for(( I = 0; I < "$1"; I++ )) do echo -n " " done } # returns result of # "echo ..." .