# # ********************* # $ bash "$d_strings"'strings.sh' - just a mish-mash dummy file with general format for bash scripts # +-----+ # ToDos # +-----+ # [chr, str] basics # str_reverse #(str) reverse-order str # str_get_length #() number of characters (number of bytes with -c) # str_get_subStr #() # +-----+ # date - functions return string [date_ymd, date_ddmmmyyyy, date_ymdhm] # see 'fileops.sh' to [get, change, put] file dates # get_UnixSec1970 #() standard Unix timecode # date expressions [date_ymd[, hm[s]], ddmmmyyyy[,_hm[s]], copy-paste expression into [cmdLin, script] : # tUnixRef_weekDaySameWeek_get_ddmmmyyyy #() get "weekDay" ddmmmyyyy for week of UnixSec1970 # statDate_to_timeUnix #() convert to linux stat format to timeUnix # yymmddhms_to_timeUnix #() convert to linux stat format, then $ date -d "$timeStat" +%s # note only works from 01Jan2000-present # timeUnix_to_ddmmmyyyy #() res ipsa loquitor # note only works from 01Jan2000-present # timeUnix_to_ddmmmyyyy #() res ipsa loquitor # tPthP_get_tDeltaDays #() returns days between file modified dates # yymmddhhmmP_to_tDeltaUnix #() returns the number of minutes between dates in YYMMDD_HM format # mmddYYY_to_ddmmmYYY #() convert mm/dd/YYYY to dd-MMM-YYYY (just use QNial!?!) # +-----+ # [human, code] forms of text, sed conversion between # Hum =human : human-readable, non-encoded format # Cde =code : safe for sed expressions like "s|$strOld|$strNew|g" # Apo =apostrophe ' : special "quote-enclosed" case, as apo can't be apo-enclosed # Quo =quotation " : special "apostophe-enclosed" case, # not used much here as almost all sed expressions are apo-enclosed # sedChrL_legend - chrL of special chrs that have to be encoded for sed # sed[x]To[y] - sedExpressions to [, de]-code chrSedL between [human, encoded] formats # strHum_sed_strCde #() convert str format [human -> code] # strCde_sed_strHum #() convert str format [code -> human] # str_strP_replace #() escape str[Old, New] then replace strOld with strNew in apo str # str[, P] are escaped if bolChrCd == 1, returns same format as input # +-----+ # str search-replace using sed # sedChrL_test #() check that chrs are [en, de]-coded consistently # strHum_sed_strCde_test_sub #() # strHum_sed_strCde_test #() str[Inn, Std]*[human, code] forms # str_strP_replace_test_sub #() str[Old, New] escaped by example-specific sedExpr # must check that str_strP_replace uses local sedExpr # str_strP_replace_test #() str[Old, New] escaped by example-specific sedEscSearch # must check that str_strP_replace uses local sedExpr # +-----+ # [str, pinn]_[rm, get, ?sed?]Between stuff - # str_chrP_rmBetween #(str chrP) rm chrs between chr[start, end] = chrP, chrP example '{}' # handy when sed is greedy and can't get result without recursion # 'fileops.sh': povr_chrP_rmBetween, but doesn't work yet # +-----+ # str funcs for special formats # problematic chrs for sedSearch= ^$\&'",*.-[]{}\|/ won't do ^$&\ for now, just '",*.[]{}-/ # str_get_width $(strInn) # colWid_chr_strInn_get_strOut #(colWid CHR strInn) pad strInn with ending spaces to reach colWid # strInn_get_strSed #(strInn) strInn to sedSearch-compatible strSedCtl (Ctrl = Control chars) # format: resSed=$( strInn_get_strSed "$strOrg" ) don't echo # subset of chrSedCtrl= '",*.[]{}-|/ won't do ^$&\ for now # strSedCtrl_get_strOrigin #(strOrigin) recover safe original str, used especially for tests # subset of chrSedCtrl= ^$\&'",*.[]{}-\|/ won't do ^$&\ for now # depends on apo-enclosed strings with '"'"' to incorporate apos # str_strP_get_pStrL #(strInn, sed[Strt, Endd], pStrL) # get multiple sedStr per line in strInn -> pLinkL # one must REVERSE [str, sed[Strt, Endd]] because: # the sequential cutting of strInn is based on "greedy sed", which finds the last occurence # sedStart [] is NOT unique, and gives mixed up results (eg