#] #] ********************* #] "$d_fileops"'0_fileops notes.txt' # www.BillHowell.ca 26Feb2023 initial, took older notes from # "$d_SysMaint"'webSite/0_website bash notes.txt' - etc # view in text editor, using constant-width font (eg courier), tabWidth = 3 #48************************************************48 #24************************24 # Table of Contents, generate with : # $ grep "^#]" "$d_fileops"'0_fileops notes.txt' | sed "s|^#\]| |" >"$d_bin"'0_fileops notes TblOfCont.txt' # ********************* #24************************24 # Setup, ToDos, 01Mar2023 [test, fix] code to replace Menus - pinnL_pStrPL_replace() create code to : insert pth in : '' cp Howell's *.html to "$d_webWork"'webPagesLocal/', replacing URL with pth in 1st line test use of "$d_webWork"'webPagesLocal/' 08Mar2023 def regexstr_tests iterative problem : incOne_create_seq( 0 1 c=0; c< ) should be ( 0 1 c ), 2 other ';for's work well... 14Sep2023 pOvrL_pStrPL_replace - should either [en, de]code [neither, both] [pOvr, pStrP] 28Sep2023 can I get ?I forget - in notes of something? 16Mar2024 povrL_pRgxP_replace(): in future, add options to pth file #08********08 #] ??Jan2026 #08********08 #] ??Jan2026 #08********08 #] ??Jan2026 #08********08 #] ??Jan2026 #08********08 #] ??Jan2026 #08********08 #] ??Jan2026 #08********08 #] 06Jan2026 convert: .csv (spreadsheet) <-> .html adapt from d_Qndfs 'file_ops.ndf' tblTab code? pain in the ass!!! QNial much bettere environment! just create QNial version? see 'file_ops.ndf' pinnTblCsv_get_tblHtm IS OP pinn - read a csv table from file, cells to [apo-str, numeric] >> adaptation (rename) of pinn_read_csvTable will this load? #08********08 #] 01Jan2026 replace of three types [rpl, sed, chrCde] +-----+ olde code strOld=$( echo "$strP" | sed "s|\(.*\):Q:.*|\1|" ) strNew=$( echo "$strP" | sed "s|.*:Q:\(.*\)|\1|" ) # becho "$povr" # -w word only not useful, as I want partial str too, # becho 'starting rpl' # povrL_pStrPL_replaceRpl #(povrL, pStrPL) rpl replace --fixed-strings # www.BillHowell.ca 01Jan2026 initial adapted from sed version povrL_pStrPL_replaceRpl() { local povrL="$1" local pStrPL="$2" local povr='' local strP='' local strOld='' local strNew='' if [[ -s "$povrL" && -s "$pStrP" ]]; then while IFS='' read -r -u 384 povr; do # becho "$povr" if [ -s "$povr" ]; then while IFS='' read -r -u 383 strP; do povr_strP_replaceRpl "$povr" "$strP" done 383< "$pStrP" else date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss") becho '' becho "$date_ymdhms povrL_pStrPL_replaceRpl error: povr doesnt exist :" becho " $povr" becho '' fi done 384< "$povrL" else date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss") becho '' becho "$date_ymdhms povrL_pStrPL_replaceRpl error: OR[povrL, pStrP] doesnt exist" becho "povrL : $povrL" becho "pStrPL : $pStrPL" becho '' fi } #08********08 #] 27Dec2025 fix povrStrPL_pStrPL_replace +-----+ olde code # # 07Dec2025 test only: done by pinnL_pStrPL_getAuto1_poutStrPL_pStrL_pStrSortUL_test_sub # becho '+--+' # becho "pinnL_pStrPL_getAuto1_poutStrPL_pStrL_pStrSortUL, $date_ymdhms" # becho "pinnL = $pinnL" # becho "pStrPL = $pStrPL" # becho "poutStrPL = $poutStrPL" # becho "pStrL = $pStrL" # becho "pStrSortUL = $pStrSortUL" # becho "p_log = $p_log" # becho '+--+' while IFS='' read -u 386 povr; do grep "$povr:Q:" "$povrStrPL" >"povrStrPLtemp" # pOldL are NOT generally unique in the StrL of povrStrPL, even for the same povr if [ -f "$povrOldPL" ]; then rm "$povrOldPL"; fi # Old = strOld while IFS='' read -u 384 Old; do grep ":Q:.*$Old" "$povrStrPLtemp" >>"$povrOldPL" # Old must be FULL 1st term of pStrPL, not just a part (unlike for pStrL) grep "$Old:Q:" "$pStrPL" >>"$pOldNewPL" done 384<"$pOldL" while IFS='' read -u 385 OldNewP; do povr_strP_replace "$povr" "$OldNewP" done 385<"$pOldNewPL" done 386<"$povrL" #08********08 #] 22Dec2025 fix pinnL_pStrPL_get_pPoutStrPL_pStrL_pStrSortUL test: see "$d_bin"'0_test/fileops/fileops test.sh' +-----+ olde code pinnL_pStrPL_get_pPoutStrPL_pStrL_pStrSortUL() { local pinnL="$1" local pStrPL="$2" # don't rm, it's in dOriginal! local pPoutStrPL="$3"; if [ -f "$pPoutStrPL" ]; then pinn_arcArchRm "$pPoutStrPL" ; fi local pStrL="$4"; if [ -f "$pStrL" ]; then rm "$pStrL" ; fi local pStrSortUL="$5" # no need to rm: it is over-written local pinn='' local pinnStrPL='' local pPinnStrPL="$d_temp"'pPinnStrPL.txt' ; if [ -f "$pPinnStrPL" ]; then rm "$pPinnStrPL"; fi local pStrPLrev="$d_temp"'pStrPLrev.txt' ; if [ -f "$pStrPLrev" ]; then rm "$pStrPLrev" ; fi local StrRev='' local StrRevL='' local pStrRevL="$d_temp"'pStrRevL.txt' # rm is done for each iteration below local StrP='' local StrPrev='' local StrtRev='' local EnddRev='' local str='' # # 07Dec2025 test only: done by pinnL_pStrPL_get_pPoutStrPL_pStrL_pStrSortUL_test_sub # becho '+--+' # becho "pinnL_pStrPL_get_pPoutStrPL_pStrL_pStrSortUL, $date_ymdhms" # becho "pinnL = $pinnL" # becho "pStrPL = $pStrPL" # becho "pPoutStrPL = $pPoutStrPL" # becho "pStrL = $pStrL" # becho "pStrSortUL = $pStrSortUL" # becho "p_log = $p_log" # becho '+--+' # extract all lines in pinn having any sedStrt (don't want reversal of pinn lines) # pPthStrL pth:linNum:str not [rev, sort]ed, just as occurs! while IFS='' read -u 072 pinn; do while IFS='' read -u 073 StrP; do sedStrt=$( echo "$StrP" | sed 's|\(.*\):Q:.*|\1|' ) grep --with-filename --line-number "$sedStrt" "$pinn" >>"$pPinnStrPL" done 073<"$pStrPL" done 072<"$pinnL" # create pStrPLrev, [Strt, Endd] reversed individually while IFS='' read -u 072 StrP; do StrtRev=$( echo "$StrP" | sed 's|\(.*\):Q:.*|\1|' | rev ) EnddRev=$( echo "$StrP" | sed 's|.*:Q:\(.*\)|\1|' | rev ) echo "$StrtRev:Q:$EnddRev" >>"$pStrPLrev" done 072<"$pStrPL" # within pPinnStrPL, extract strWithin [sedStrt, sedEndd] while IFS='' read -u 073 pinnStrPL; do pinn=$( echo "$pinnStrPL" | sed 's|\(.*\):[0-9]\+:.*|\1|' ) strRev=$( echo "$pinnStrPL" | sed 's|.*:[0-9]\+:\(.*\)|\1|' | rev ) # appends multiple sedStr per line to pStrRevL if [ -f "$pStrRevL" ]; then rm "$pStrRevL"; fi strRev_pStrPLrev_get_pStrLrev "$strRev" "$pStrPLrev" "$pStrRevL" while IFS='' read -u 071 StrPrev; do # is this append? YES, but maybe zeroed @start then append? while IFS='' read -u 070 StrRev; do str=$( echo "$StrRev" | rev ) echo "$pinn:Q:$str" >>"$pPoutStrPL" echo "$str" >>"$pStrL" done 070<"$pStrRevL" done 071<"$pStrPLrev" done 073<"$pPinnStrPL" cat "$pStrL" | sort -u >"$pStrSortUL" } # alternately, just sed each term? # while IFS='' read -r -u 384 povrL; do # povr=$( echo "$povrStrP" | sed 's|\(.*\):Q:.*|\1|' ) # if [ -s "$povr" ]; then # Str=$( echo "$povrStrP" | sed 's|.*:Q:\(.*\)|\1|' ) # while IFS='' read -r -u 383 strP_replace; do # becho "$povr" # povr_strP_replace "$povr" "$strP" # done 383< "$pStrPL" # else # becho "error: povr doesnt exist :" # becho " $povr" # fi # done 384< "$povrStrPL" while IFS='' read -u 9 StrSortUL && read -u 8 -r StrReplace; do echo "$StrSortUL:Q:$StrReplace" >>"$pStrPLout" done 9<"$pStrSortUL29" 8<"$pStrReplac" # replace strings as per pStrPLout if [ "$funcName" == 'povrStrPL_pStrPL_replace' ]; then povrStrPL_pStrPL_replace "$povrStrPL" "$pStrPLout" else becho "povrStrPL_pStrPL_replace error: unrecognized funcName: $funcName" fi 26Dec2025 # sed 's|\(.*\):Q:.*|\1|' "$povrStrPtemp" >"$povrLtemp" # while IFS='' read -r -u 386 povr; -u 385 StrOld; do # while IFS='' read -r -u 384 RepOld; -u 383 RepNew; do # bolNew=$( echo "$StrOld" | grep "$RepOld" ) # if ! [ "$bolNew" == '' ]; then povr_strP_replace "$povr" "$RepOld:Q:$RepNew" fi # done 384<"$pRepOldL" 383<"$pRepNewL" # done 386<"$povrL" 385<"$pStrOldL" # useless: just runs pinnL_pStrPL_get_poutStrPL_pStrL_pStrSortUL # becho '+-----+' # fName='www.BillHowell.ca.txt' # case='01' # comment='extract all [Href, Img] links' # pinnL="$dOrig"'pinnL '"$fName" # pStrPLinn="$dOrig"'pStrPL [Hrf, Img] links.txt' # pStrPLout="$dTest"'pStrPL [Hrf, Img] links.txt' # povrStrPL_pStrPL_replace_test_sub while IFS='' read -u 384 RepOld && read -u 383 RepNew; do RepNew=$( grep "$povrStrPtemp" ) povr_strP_replace "$povr" "$RepOld:Q:$RepNew" done 384<"$pRepOldL" 383<"$pRepNewL" while IFS='' read -u 386 povr; do grep "$povr:Q:" "$povrStrPL" >"$povrStrPLtemp" grep "$povr:Q:" "$pStrPL" >"$povrStrPLtemp" ?????????? while IFS='' read -u 384 RepOld; do RepNew=$( grep "$RepOld" "$povrStrPLtemp" | sed 's|.*:Q:\(.*\)|\1|' ) echo "RepNew= $RepNew" povr_strP_replace "$povr" "$RepOld:Q:$RepNew" done 384<"$pRepOldL" done 386<"$povrL" # local pNewL="$d_temp"'povrStrPL_pStrPL_replace pNewL.txt' local pStrOldL="$d_temp"'povrStrPL_pStrPL_replace pStrOldL.txt' local strL='' # sed 's|.*:Q:\(.*\)|\1|' "$povrStrPL" | sort -u >"$pStrL" # sed 's|.*:Q:\(.*\)|\1|' "$pStrPL" >"$pNewL" #08********08 #] 18Dec2025 fileops.sh: pNotes_str_get_dateBefore_StrLine_dateAfter # $ bash "$d_fileops"'fileops run.sh' edit pNotes_str_get_dateBefore_StrLine_dateAfter_runL change: "$pNotes" 'Myrnohrad' +-----+ olde code #if [ "$linNumStr" == "$linStr" ]; then bolStr=1; else bolStr=0; fi ^\([0-9]\+\):.* #08********08 #] 15Dec2025 PL separator: change from \t to :Q: - reversible, somehat unique, like diff with line-number many seds to change: [\x9, : - should convert to --line-number] first pass: fileops.sh fileops test.sh none affected rerun test to see : povrL_pStrPL_replace_test povrL_pStrPL_replaceType_allTests >> oops : povrL_pStrPL_test_sub error: unrecognized test: povrStrPL_pStrPL_replace povrL_pStrPL_test_sub error: unrecognized test: povrStrPL_pStrPL_replace >> all tests have this glitch >> fixed, naming problem rerun with corrected pStrPL: replace \t with :Q: #08********08 #] 09Dec2025 next step: [upgrade, test] povrOldPL_pOldNewPL_replace 10Dec2025 change: povrL_pOldNewPL_replace to : povrStrPL_pSedPL_replace USE rpl for --fixed-strings (-F) SEE COMMENTS 11Dec025 "$d_SysMaint"'Linux/sed notes.txt' #08********08 #] 09Dec2025 next step: [upgrade, test] pinnL_pSedPL_get_pPoutStrPL_pStrL_pStrSortUL pinnL_pSedPL_get_pPoutStrPL_pStrL_pStrSortUL pPoutStrPL www.BillHowell.ca.txt has "raw" link-line, not clean hyperlinks >> OK #08********08 #] 09Dec2025 re-install rpl - replace strings in files, command-line --fixed-strings = no regExpr, etc For simple text replacement, all the work I've done to overcome the huge challenges of regExpr has been a waste of time. Still essential for complex stuff, especially with chrCde. chrCde = character encoding of sed problematic chrs ^$\&'",*.[]{}-\|/ (I question `/, which maybe OK?) For almost all hyperlink work (most of what I do for webLocal), rpl should be much [bett, fast, clean]er. created pPovrOldPL_pOldNewPL_replaceNoRegexpr from pPovrOldPL_pOldNewPL_replace #08********08 #] 06Dec2025 create pPovrOldPL_pOldNewPL_replace: can't find older versions!!??!! re-invent the wheel... +-----+ olde code # while IFS='' read -u 9 strOldNewP; do # strOld=$( echo "$strOldNewP" | sed 's|\(.*\) .*|\1|' ) # strNew=$( echo "$strOldNewP" | sed 's|.* \(.*\)|\1|' ) # grep "$strOld" "$pPthStrL" >"$pPovrOldPL" # generates MANY hits! # sed 's|\(.*\):[0-9]\+:.*|\1|' "$pPovrOldPL" | sort -u >"$pPovrL" # becho "strOld= $strOld" # becho "strNew= $strNew" # # while IFS='' read -u 8 povr; do # # # becho "$povr" # # # argument symbols bolArXiv bolChrCd povr strOldNewP # # povr_strP_replace "$povr" "$strOldNewP" # # done 8<"$pPovrL" # # becho '' # done 9<"$pOldNewPL" # pinnL_pSedPL_getWithin_pStrL #(bolPrint pinnL pSedPL pStrL) get pStrL within pSedPL # 06Dec2025 antiquated! replaced by pPovrOldPL_pSedPL_get_pPthStrWithinPL # 24Nov2025 [arg, output]s are reversed below, as most often sedStrt is unique, not sedEndd # note that this works differently from pinnL_pSedPL_get_pPthStrL_pStrL below # sedExpr selects lines from pinnL, sedStrt might have to escape chrs ^$\&'",*.[]{}-\|/ (not normally) # archives povrStrL, (links, but not robust?), # 10May2025 initial # 19Nov2025 pinnL_pSedPL_getWithin_pStrL: tac (reverse of cat) no good - reverses lines, not chrs! pinnL_pSedPL_getWithin_pStrL() { local bolPrint="$1" local dWork="$2" local pinnL="$3" local pSedPL="$4" local pStrL="$5" local pinn='' local pTmp="$d_temp"'pinnL_pSedPL_getWithin_pStrL temp.txt' local sedStrP='' t_startSec=$( funcStart_pLog 'pinnL_pSedPL_get_povr' ) if [ "$bolPrint" == 1 ]; then becho '' becho '+-----+' becho "pinnL_pSedPL_getWithin_pStrL, $date_ymdhms" becho "pinnL = $pinnL" becho "pSedPL= $pSedPL" becho "pStrL = $pStrL" becho "p_log = $p_log" #p_log -> set by calling func because of need for 'becho' etc fi if [ -f "$pStrL" ]; then pinn_archiveLocalRm "$pStrL"; fi if [ -f "$pTmp" ]; then rm "$pTmp"; fi # pinn_sedExpr_revGet_pStrL does [fwd, bckwd] double-sweep to pull out str # Do NOT escape "problematic sed search chrs -> that is done by pinn_sedExpr_revGet_pStrL while IFS='' read -u 072 pinn; do while IFS='' read -u 073 sedStrP; do sedRev1=$( echo "$sedStrP" | sed 's|\(.*\)\x9.*|\1|' | rev ) sedRev2=$( echo "$sedStrP" | sed 's|.*\x9\(.*\)|\1|' | rev ) pinn_sedExpr_revGet_pStrL 0 "$sedRev1" "$sedRev2" "$pinn" "$pTmp" done 073<"$pSedPL" done 072<"$pinnL" if [ -f "$pTmp" ]; then sort -u "$pTmp" >"$pStrL" else becho "pinnL_pSedPL_getWithin_pStrL error: no pTmp= $pTmp" fi } # 26Jun2025 tests # 18h33m 26Jun25$ echo ' HREF=" ">' | sed 's|\(.*\)\x9.*|\1|' # HREF=" # >>OK # 18h35m 26Jun25$ echo ' HREF=" ">' | sed 's|.*\x9\(.*\)|\1|' # "> # >> OK sedStrtRev=$( echo "$sedRevP" | sed 's|\(.*\)\x9.*|\1|' ) sedEnddRev=$( echo "$sedRevP" | sed 's|.*\x9\(.*\)|\1|' ) #08********08 #] 06Dec2025 pinnL_pSedPL_get_pPthStrWithinPL() - want list of all links, not just the line strRev_pSedPRevL_get_pStrRevL: doesn't exist! I forgot to do this func!!?? but this should have given errors for unknown func!?!???? oops - see strings.sh >> func is a mess! ##08********08 #] 03Dec2025 search "unix program to replace a string in a file" sed problems again. #] use OR[povrL_pStrP_replaceChrCde, QNial] 04Dec2025 works so far, haven't yet done "# post-func processing" now will check povrL_pStrP_replaceChrCde_test() +-----+ https://www.computerhope.com/unix/replace.htm Linux replace command Updated: 06/01/2025 by Computer Hope replace command On Unix-like operating systems, the replace command makes modifications to strings of text in files or the standard input. >> Howell: not in LinuxMint cmds, Software Manager (LMSW) but LMSW does have : jdReplace is a simple mass search and replace tool. You set a directory, a text to replace, the replacement and click OK. jdReplace will do the rest. >> Howell: I installed but immediately removed. Can't see way to specify only one file? dangerous also, this is GUI, not command based! (useless for me) Rpl is an intelligent search and replacement utility. It will change strings with new strings in multiple text files at the same time. rpl can verify, find and edit several plain texts quickly. 03Dec2025 quick test: 14:03 3Dec2025$ rpl -iF '&",.*/\$^[]-{}|' '' '/home/bill/web/bin/0_test/fileops/dOriginal/0_test/fileops/dOriginal/sedChrL problematic (copy).txt' rpl: The given filename patterns did not match any files! 14:09 3Dec2025$ rpl '&",.*/\$^[]-{}|' '' '/home/bill/web/bin/0_test/fileops/dOriginal/sedChrL problematic (copy).txt' rpl: Replacing "&",.*/\$^[]-{}|" with "" (case sensitive; partial words matched) rpl: Bad regex &",.*/\$^[]-{}| (unterminated character set) ~ 14:09 3Dec2025$ rpl '&,.*/\$^[]-{}|' '' '/home/bill/web/bin/0_test/fileops/dOriginal/sedChrL problematic (copy).txt' rpl: Replacing "&,.*/\$^[]-{}|" with "" (case sensitive; partial words matched) rpl: Bad regex &,.*/\$^[]-{}| (unterminated character set) ~ >> I don't want regexpr!!! 14:12 3Dec2025$ rpl -iF '&,.*/\$^[]-{}|' '' '/home/bill/web/bin/0_test/fileops/dOriginal/sedChrL problematic (copy).txt' rpl: Replacing "&,.*/\$^[]-{}|" with "" (ignoring case; partial words matched) rpl: 0 matches replaced in 0 out of 1 file ~ >> useless - same problems as sed #08********08 #] 03Dec2025 clean up fileops.sh povr[L] functions - add warning comments, reorder replace: povr before pinn +-----+ olde code # povr_chrP_rmBetween #(povr chrP) with povr, rm chrs between chr[start, end] = chrP (noWork yet!!) # do NOT use povr functions without first checking that 0_tests povr still work!!! # example 'povr_chrP_rmBetween povr {}' # handy when sed is greedy and can't get results without facy back-&-forth recursion # this func does NOT recurse, intentionally, won't work across lines (maybe xargs?) # 21May2025 move to 'fileops.sh'!! # 01Feb2024 initial, should move to filops.sh soon povr_chrP_rmBetween() { povr="$1" chrP="$2" pTmp="$d_temp"'povr_chrP_rmBetween tmp.txt' # if [ -s "$povr" ]; then # pinn_archiveLocal "$povr" # if [ -s "$pTmp" ]; then rm "$pTmp"; fi # while read -u 9 line; do # liner=$( str_chrP_rmBetween "$line" "$chrP" ) # echo "$liner" # # echo "$liner" >>"$pTmp" # done 9< "$povr" # else # echo "povr_chrP_rmBetween() error: povr doesnt exist" # fi echo 'no-finc' >"$pTmp" #mv "$pTmp" "$povr" } #tst # have to check result on terminal #tst povr_chrP_rmBetween "$d_web"'References/Mathematics/0_math theorem list, wikipedia1.txt' '{}' #08********08 #] 02Dec2025 povrL_pStrP_replace cleanup +-----+ olde code this is not necessary?!! I'm just replacing a str! cp "$povr" "$povr_tmp" while IFS='' read -r -u 385 strP; do # ignores [comment, empty, nTab != 1] lines #bolTabInStr=$( echo "$strP" | sed 's|\x9|ztbz|' | grep -c -o 'ztbz' ) commentChrs=0 commentChrs=$( echo "$strP" | cut --bytes=1,2,3 ) if ! [ '#] ' == "$commentChrs" ]; then nTab=$( echo "$strP" | tr \\t \\n | wc -l ) nTab=$(( $nTab - 1 )) if [[ 1 = "$nTab" ]]; then local strFnd=$( echo "$strP" | sed 's|\x9.*||' ) local nStrFnd=$( grep -c "$strFnd" "$povr_tmp" ) if [[ 0 < "$nStrFnd" ]]; then # becho '' # becho "$nStrFnd : $strP" povr_strOld_strNew_replace "$povr_tmp" "$strStrt" "$strNew" fi fi fi done 385< "$pStrPtmp" cp "$povr_tmp" "$pOvr2Tmp" # diff to know if original file to be replaced # probably unnecessary ?- nStrFnd prevents individual strFnd for changing povr diff "$povr" "$pOvr2Tmp" --suppress-common-lines | grep "<" | sed 's/< //' >"$pDiffTmp" if [ -s "$pDiffTmp" ]; then cp "$pOvr2Tmp" "$povr" # becho "changed : $povr" #else fi >>don't put diff & junk into basic routine! # povrL_pStrP_replaceChrCde #(bolBecho bolArXiv bolChrCd povrL pStrP) slow processing # normally set [bolArXiv, bolChrCd] both = 1 to ensure [arXiv, character encoding] # 16Feb2023 initial as povrL_pStrP_replace(), or at least beore 14Sep2023 # 30Nov2025 split from povrL_pStrP_replace(): problems with if statements, don't need chrCde normally # 02Dec2025 further streamline to call povrL_pStrP_replaceChrCde() { # change the "process to OR[func, process] as needed when run local processName='processWebSite_find' local functionCmt='povrL_pStrP_replaceWith_Becho_ArXiv_ChrCde, used often to extract webSite links' funcStart "$d_webWork" "$processName" "$functionCmt" local bolEcho="$1" local bolArXiv="$2" local povrL="$3" local pStrP="$4" if [ -f "$pLogStrP337" ]; then pinn_arcArch "$pLogStrP337" # rm "$pLogStrP337" fi if [[ -s "$povrL" && -s "$pStrP" ]]; then local povr_tmp="$d_temp"'povrL_pStrP_replace pOvr1Tmp.txt' local pOvr2Tmp="$d_temp"'povrL_pStrP_replace pOvr2Tmp.txt' local pStrPtmp="$d_temp"'povrL_pStrP_replace pStrPtmp.txt' local pDiffTmp="$d_temp"'povrL_pStrP_replace pDiffTmp.txt' if [[ "$bolEcho" = 1 ]]; then becho '' becho '************************' becho "$date_ymdhms "'"$d_bin"bin logs/povrL_pStrP_replace funcFamily pLog.txt' becho '' becho "bolChrCd = $bolChrCd" becho "povr_tmp = $povr_tmp" becho "pOvr2Tmp = $pOvr2Tmp" becho "pStrPtmp = $pStrPtmp" becho "pDiffTmp = $pDiffTmp" becho 'povr files processed : ' becho '' fi # 11Oct2023 check pStrP for problems # eg only 1*\t on a strP line (not comment etc) pHum_sed_pCde "$pStrP" "$pStrPtmp" while IFS='' read -r -u 384 povr; do # becho "$povr" if [ -s "$povr" ]; then if [[ 1 = "$bolArXiv" ]]; then pinn_arcArch "$povr" fi pHum_sed_pCde "$povr" "$povr_tmp" while IFS='' read -r -u 385 strP; do # ignores [comment, empty, nTab != 1] lines #bolTabInStr=$( echo "$strP" | sed 's|\x9|ztbz|' | grep -c -o 'ztbz' ) commentChrs=0 commentChrs=$( echo "$strP" | cut --bytes=1,2,3 ) if ! [ '#] ' == "$commentChrs" ]; then nTab=$( echo "$strP" | tr \\t \\n | wc -l ) nTab=$(( $nTab - 1 )) if [[ 1 = "$nTab" ]]; then # both of the following are in Cde format (tab=\x9 is NOT translated!) local strFnd=$( echo "$strP" | sed 's|\x9.*||' ) local nStrFnd=$( grep -c "$strFnd" "$povr_tmp" ) if [[ 0 < "$nStrFnd" ]]; then becho '' becho "$nStrFnd : $strP" povr_strStrt_strEndd_replace "$povr_tmp" "$strStrt" "$strEndd" fi fi fi done 385< "$pStrPtmp" # revert to Human code in preparation for diff pCde_sed_pHum "$povr_tmp" "$pOvr2Tmp" # diff to know if original file to be replaced # probably unnecessary ?- nStrFnd prevents individual strFnd for changing povr diff "$povr" "$pOvr2Tmp" --suppress-common-lines | grep "<" | sed 's/< //' >"$pDiffTmp" if [ -s "$pDiffTmp" ]; then cp "$pOvr2Tmp" "$povr" # becho "changed : $povr" #else fi else date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss") if [[ "$bolEcho" = 1 ]]; then becho '' becho "$date_ymdhms povrL_pStrP_replace error: povr doesnt exist :" becho " $povr" becho '' fi fi done 384< "$povrL" else date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss") if [[ "$bolEcho" = 1 ]]; then becho '' becho "$date_ymdhms povrL_pStrP_replace error: OR[povrL, pStrP] doesnt exist" becho "povrL : $povrL" becho "pStrP : $pStrP" becho '' fi fi if [[ "$bolEcho" = 1 ]]; then becho "start: $date_ymdhms" date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss") becho "ender: $date_ymdhms" becho '' fi funcEnder "$d_webWork" "$d_webWork" "$processName" "$functionCmt" } #08********08 #] 02Dec2025 remove povr_strP_replaceChrCde: redundant, just use povrL_pStrP_replaceChrCde # more effort to just use once, but don't want to maintain extra code +-----= olde code # povr_strP_replaceChrCde #(bolArXiv povr pStrP) # character codes (chrCde) used for [povr, strP] to avoid "problematic characters" # 10Oct2023 no attempt to limit povr over-write ONLY when it differs from original # (see povrL_pStrP_replace for that) # www.BillHowell.ca 01Jun2021 initial, 16Sep2023 handle [no-tab, empty strP] # pLogStrP337 ='povrL_pStrP_replace funcFamily pLog.txt', defined in Setup section above povr_strP_replaceChrCde() { local bolArXiv="$1" local povr____="$2" local strP____="$3" if [ -s "$povr____" ]; then local pov1Tmp="$d_temp"'povr_strP_replace temp1.txt' local pov2Tmp="$d_temp"'povr_strP_replace temp2.txt' if [ 1 -eq "$bolArXiv" ]; then pinn_arcArch "$povr____" fi pHum_sed_pCde "$povr____" "$pov1Tmp" strP____=$( strHum_sed_strCde "$strP____" ) povr_strP_replace "$pov1Tmp" "$strP____" cp "$pov1Tmp" "$pov2Tmp" pCde_sed_pHum "$pov2Tmp" "$povr____" else becho "$date_ymdhms povr_strP_replaceChrCde error, could not get :" becho " $povr____" fi } #08********08 #] 30Nov2025 povrL_pStrP_replace: if problems, make separate [becho, arXiv, chrCde] version # 30Nov2025 # make separate func for [becho, arXiv, ]s # make separate func for [arXiv, becho]s povr_strP_replace assumes pre-[arXiv, chrCde, povr, strP] checks are done BEFORE calling this function #08********08 #] 29Nov2025 remove povrL_pStrP_replace_test_sub: redundant? +-----+ olde code "$d_bin"'0_test/fileops/fileops test.sh' # povrL_pStrP_replace_test_sub #() does diff between [res, std] files # 11Oct2023 careful of funcNam : # povr_strP_replace_run is name used in fileops.sh for base function # 05Aug2023 initial povrL_pStrP_replace_test_sub() { comnt007="$1" d_wrk007="$2" # uses pLogg047 from calling function f_res007="$3" f_std007="$4" f_dif007="$5" becho "comnt = $comnt007" becho "f_res = $f_res007" becho "f_std = $f_std007" becho "f_dif = $f_dif007" p_res007="$d_wrk007$f_res007" p_std007="$d_wrk007$f_std007" p_dif007="$d_wrk007$f_dif007" if [[ -s "$p_res007" && -s "$p_std007" ]]; then tUnixAcs047=$( pinn_timeAcsTo_timeUnix "$p_res007" ) tDelta=$(( tUnixBeg047 - tUnixAcs047 )) echo "tDelta = $tDelta" if [ 0 -le "$tDelta" ]; then diff "$p_std007" "$p_res007" --suppress-common-lines >"$p_dif007" if [ -s "$p_dif007" ]; then becho 'error: has p_dif output' else becho 'correct output' fi else echo 'no pStrP in pover (p_res dateMod <= preFunc)' becho 'no pStrP in pover (p_res dateMod <= preFunc)' fi else becho 'OR[p_res, p_std]*[empty, dont exist]' becho " $p_res007" becho " $p_std007" fi becho '' } cp "$dOriginFil"'fileops.sh' "$dWork"'case 1: fileops.sh' cp "$dOriginFil"'sedChrL legend simple.txt' "$dWork"'case 1: sedChrL legend simple.txt' cp "$dOriginFil"'urls interWebPage short-to-longs.txt' "$dWork"'case 1: urls interWebPage short-to-longs.txt' #08********08 #] 24Nov2025 mv [fileops, strings] funcs to own directories, huge number of file changes... source "$d_strings"'strings.sh' source "$d_fileops"'fileops header.sh' wrkSpcL_arcArch(): for some unknown reason, it's not archiving 0_test files (2 different dirs) #08********08 #] 22Jun2025 create transcript_unite_nLines #() keep timestamp each n lines of transcript +-----+ olde code elif [ elif [ "$nLine" >> 0 ]; then echo ' ' >>"$pout" # save paragraph cat "$ptmp" | tr \\n ' ' | sed 's| \([0-9]*:[0-9]*\) | |g' >>"$pout" rm "$ptmp" bolInn=0 echo ' ' >>"$pout" fi else echo "$line" >>"$ptmp" bolInn=1 #08********08 #] 19May2025 continued work, returning to: list of links test using pinnL_pSedExpL_get_povr() 20May2025 working for reviews of Howell +-----+ olde code # clean up pinn956 : sed 's|\x27|\"|g' "$pinn956" >"$pinnCl431" # >> nyet - most lines won't have HREF etc, # appends each result to paddTmp956, details below must be changed for differen apps # find "$d_web"'Bill Howells book [note, review]s/' -type f -name "*.link.txt" | sort | tr \\n \\0 | xargs -0 -IFILE grep '\"\$' "FILE" | sed 's|.*\"\$\(.*\)|"$\1|' | tr "'" '"' | sed 's|\"\$\(.*\)\"\"\(.*\)\/\(.*\)\"|
  • \n\t\3<\/a>|' >"$pLnkRaw" #08********08 #] 05May2025 fileops: fix [dir_archive_[pArcDate, pArcArch, dirDated], pinn_arcArch] I had to comment-out printfs to get subs to work!!???!!!!!????? >> I don't understand why +-----+ # pth_get_dir #(pth) retrieve dir holding pth, dir must exist or error # 13Jul2022 initial, 28Nov2024 unix "dirname" does this!! pth_get_dir() { local pInn="$1" local dPth='' local result='' dPth=$( echo "$pInn" | sed 's|\(.*\)\/.*|\1\/|' ) # printf \n "pth_get_dir pInn= $pInn" # printf \n "pth_get_dir dPth= $dPth" if [ -d "$dPth" ]; then result="$dPth" else result='pth_get_dir error: dir not found' fi echo "$result" } +-----+ # pth_get_pArcArch #(pinn) of form "$dArc$fNoX archive.$fExt", creates dArc if required # end with ' archive.' # 20Jan2024 initial pth_get_pArcArch() { local pInn="$1" local dPth=$( pth_get_dir "$pInn" ) # dPth = directory of path # printf "\n" "pth_get_pArcArch, zyzy dPth: $dPth" local result='' if [ -d "$dPth" ]; then dArc=$( pth_get_dArchive "$pInn" ) # ensures that z_Archive is created fNam=$( pth_get_fnam "$pInn" ) fNoX=$( fNam_get_fBase "$fNam" ) fExt=$( fNam_get_ext "$fNam" ) result="$dArc$fNoX archive.$fExt" else result='pth_get_pArcArch error: dir not found' fi # printf "\n" "pth_get_pArcArch result: $result" echo "$result" } +-----+ #08********08 #] 04May2025 redefined pinn_archiveLocal -> pinn_arcArch I removed pinn_backupDatedTo_zArchive (now is redundant) +-----+ olde code # pinn_backupDatedTo_zArchive #(pInn) (obsolete) backup file to a z_Archive pre-fNam-dated now # zArchive is [specific, with respect] to each path, it is not an overall zArchive # Notice that there is no error output (write) - must be handeled by the calling optr! pinn_backupDatedTo_zArchive() { # local date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss") # echo >>"$p_log" "$date_ymdhms pinn_backupDatedTo_zArchive" local pinn="$1" local pArc=$( pth_get_pArchive "$pinn" ) # echo "$pArc" cp -p "$pinn" "$pArc" } if [ -f local pDrc="$dDrc$fnam $date_ymdhms.$fext" # echo "dDrc= $dDrc" # echo "date_ymdhm= $date_ymdhms" # echo "pDrc= $pDrc" #08********08 #] 18Jan2025 search 'Linux bash and count lines in file': wc -l example.txt +-----+ https://www.howtogeek.com/ways-to-count-number-of-lines-in-linux-files/ 6 Ways to Count the Number of Lines in a Linux File Haroon Javed Published Dec 4, 2023 wc -l example.txt #08********08 #] 12Jan2025 pth_get_dir - fix #08********08 #] 12Jan2025 do "local" statements, remove 3-digit function codes from library, test "$d_bin"'fileops run.sh' run (uncomment) : +-----+ pinn_timeModTo_yymmddhms "$d_SysMaint"'Linux/timestamps notes.txt' 15h17m 12Jan25$ bash "$d_bin"'fileops run.sh' 230920 20h29m25s ~ >> OK, as per nemo filMgr +-----+ 16h21m 12Jan25$ bash "$d_bin"'fileops run.sh' code_get : generate a list of existing library codes see : "$d_bin""codeL [symbol. function].txt" code_make : generate a unique new 3-digit [symbol. function] code for a library 205 ~ >> OK, works #08********08 #] 16Mar2024 povrL_pRgxP_replace(): in future, add options to pth file #08********08 #] 15Mar2024 povrL_pRgxP_replace(): revamp arrays nested- test ndfs revamping : /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- data templates.ndf /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- testGroupsCluster.ndf /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- testOptrs.ndf 14:38$ bash "$d_bin"'fileops run.sh' ~ >> no changes!!??? oops, I used povrL_pStrP_replace 15:05$ bash "$d_bin"'fileops run.sh' ~ >> still no changes 15:23$ bash "$d_bin"'fileops run.sh' /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- data templates.ndf sed: -e expression #1, char 35: invalid reference \1 on `s' command's RHS /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- testGroupsCluster.ndf sed: -e expression #1, char 35: invalid reference \1 on `s' command's RHS /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- testOptrs.ndf sed: -e expression #1, char 35: invalid reference \1 on `s' command's RHS ~ Hah! was missing `\ in front of [()] - bash not geany have to replace ndfs from archive 15:23$ bash "$d_bin"'fileops run.sh' /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- data templates.ndf sed: can't read : No such file or directory /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- testGroupsCluster.ndf sed: can't read : No such file or directory /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- testOptrs.ndf sed: can't read : No such file or directory ~ >> files were wiped out again!?? I put archive in povrL_pRgxP_replace, then call povr_rgxP_replace no archive : if [ -s "$povr982" ]; then if [ 1 -eq "$bolArXiv982" ]; then pinn_archiveLocal "$povr982" fi while IFS='' read -r -u 983 rgxP982; do povr_rgxP_replace 0 "$povr982" "$rgxP982" done 983< "$pRgxPTmp982" change : sed "s|$rgxOld448|$rgxNew448|g" "$pov1Tmp448" >"$povrTmp448" to : sed "s|$rgxOld448|$rgxNew448|g" "$povr____448" >"$povrTmp448" 15:53$ bash "$d_bin"'fileops run.sh' /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- data templates.ndf /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- testGroupsCluster.ndf /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- testOptrs.ndf ~ >> now it runs without rm file contents >> but does it work? checks : tmplt grp ops y idx\([LA]*\) ndx\1 n n ary\([LA]*\) nry\1 often ary without [LA] n slc\([LA]*\) slcN\1 n ary\([A-Za-z]*\)_ nry\1_ n _slc\([LA_]*\)_ _slcN\1_ ? _replace\([A-Za-z0-9]*\)_ _put\1_ >> none of these worked!!!!? "$d_temp"'povrL_pRgxP_replace pRgxPTmp.txt' only has : _replace\([A-Za-z0-9]*\)_ _put\1_ >> oops! only one showing : _replace\([A-Za-z0-9]*\)_ _put\1_ move out of while loop! if [ -f "$pRgxPTmp982" ]; then rm "$pRgxPTmp982" fi 16:26$ bash "$d_bin"'fileops run.sh' /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- data templates.ndf /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- testGroupsCluster.ndf /home/bill/web/Qnial/code develop_test/arrays nested/arrays nested- testOptrs.ndf ~ tmplt grp ops idx\([LA]*\) ndx\1 ary\([LA]*\) nry\1 often ary without [LA] slc\([LA]*\) slcN\1 ary\([A-Za-z]*\)_ nry\1_ _slc\([LA_]*\)_ _slcN\1_ _replace\([A-Za-z0-9]*\)_ _put\1_ OK examples : nry_ _ndx_ _slcN_ >> actually, it looks like it mostly worked! 16:31 take a break, I'm tired #08********08 #] 15Mar2024 check rm [povr_pStrP_replace, povr_pRgxP_replace, povrL_rgxP_replace] will no longer use! (error prone, excess [code, opNam]) I updated povrL_pRgxP_replace +-----+ olde code # povr_pStrP_replace(bolArXiv bolChrCd povr pStrP) sed replace encoded (pStrP, povr) # pStrP : put dir changes AFTER pth changes - safer, [no-tab, empty] pStrP lines are OK # example see : "$d_bin"'0_test/fileops test.sh' # tightly tied to function called, povr_strP_replace : easy to make symbol errors!! # www.BillHowell.ca 01Jun2021 intitial, 03Mar2023 unfinished, 07Aug2023 revamped # 16Sep2023 handle [no-tab, empty lines in pStrP] povr_pStrP_replace() { bolArXiv607="$1" # 1= archive povr bolChrCd607="$2" # 1= escape (code) human <--> sed search-replace povr____607="$3" # file to overwrite after sed search-replace pStrP___607="$4" # str[Old, New] search-replace pairs # echo >>"$pLog607" "povr = $povr____607" # echo >>"$pLog607" "pStrP = $pStrP___607" povr_tmp607="$d_temp"'povr_pStrP_replace povr temp.txt' pStrPtmp607="$d_temp"'povr_pStrP_replace pStrP temp.txt' if [[ -s "$povr____607" && -s "$pStrP___607" ]]; then if [ 1 -eq "$bolArXiv607" ]; then pinn_archiveLocal "$povr____607" fi if [ 1 -eq "$bolChrCd607" ]; then pHum_sed_pCde "$povr____607" "$povr_tmp607" pHum_sed_pCde "$pStrP___607" "$pStrPtmp607" else cp -p "$povr____607" "$povr_tmp607" cp "$pStrP___607" "$pStrPtmp607" fi while IFS='' read -r -u 607 strP607; do povr_strP_replace_run "$povr_tmp607" "$strP607" done 607< "$pStrPtmp607" if [ 1 -eq "$bolChrCd607" ]; then pCde_sed_pHum "$povr_tmp607" "$povr____607" else mv "$povr_tmp607" "$povr____607" fi else date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss") echo >>"$pLog384" "$date_ymdhms povr_pStrP_replace error: OR[povr, pStrPL] doesnt exist :" echo >>"$pLog384" "povr = $povr____384" echo >>"$pLog384" "pStrP = $pStrP___384" echo >>"$pLog384" '' fi } # povrL_strP_replace(bolArXiv bolChrCd povrL strP) sed replace encoded (pStr, povrL) # NO LONGER available - dangerous mixups, just use povrL_pStrP_replace # povr_pRgxP_replace(bolArXiv bolChrCd povr pRgxP) sed replace encoded (pRgxP, povr) # www.BillHowell.ca 17Sep2023 initial copy of strP form, some adjustments povr_pRgxP_replace() { bolArXiv457="$1" # 1= archive povr povr____457="$2" # file to overwrite after sed search-replace pRgxP___457="$3" # str[Old, New] search-replace pairs # echo >>"$pLog982" "povr = $povr____457" # echo >>"$pLog982" "pRgxP = $pRgxP___457" #pLog982 = 'povrL_pRgxP_replace funcFamily log.txt', defined in Setup section above if [[ -s "$povr____457" && -s "$pRgxP___457" ]]; then if [ 1 -eq "$bolArXiv457" ]; then pinn_archiveLocal "$povr____457" fi while IFS='' read -r -u 457 rgxP457; do povr_rgxP_replace 0 "$povr____457" "$rgxP457" done 457< "$pRgxP___457" else date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss") echo >>"$pLog982" "$date_ymdhms povr_pRgxP_replace error: OR[povr, pRgxPL] doesnt exist :" echo >>"$pLog982" "povr = $povr____457" echo >>"$pLog982" "pRgxP = $pRgxP___457" echo >>"$pLog982" '' fi } # povrL_rgxP_replace(bolArXiv bolChrCd povrL rgxP) sed replace encoded (pStr, povrL) UNTESTED! # [all povrL, rgxP] are escaped if p[ov, st]Esc961 == 1 # z_Archive each povrL (file listed), rgxP=(strOld, strNew) # tightly tied to function called, povr_rgxP_replace : easy to make symbol errors!! # www.BillHowell.ca 17Sep2023 initial copy of strP form, some adjustments povrL_rgxP_replace() { bolArXiv961="$1" povrL___961="$2" rgxP____961="$3" #pLog982 = 'povrL_pRgxP_replace funcFamily log.txt', defined in Setup section above if [ -s "$povrL961" ]; then while IFS='' read -u 961 povr961; do povr_rgxP_replace "$bolArXiv961" "$povr961" "$rgxP____961" done 961<"$povrL___961" else date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss") echo >>"$pLog982" "$date_ymdhms povrL_rgxP_replace error: povrL doesnt exist : " echo >>"$pLog982" "povrL : $povrL___961" echo >>"$pLog982" '' fi } #08********08 #] 27Feb2024 change povrL_pStrP_replace because of bookmarks: '^#] ' comment, not `# change: chrOne=0 chrOne=$( echo "$strP384" | cut --bytes=1 ) if ! [ '#] ' == "$chrOne" ]; then to: commentChrs=0 commentChrs=$( echo "$strP384" | cut --bytes=1,2,3 ) if ! [ '#] ' == "$commentChrs" ]; then test : 14:25$ strP384='#] 27Feb2024 OOPS!!! ^# makes function ignore line - changes wont be made' ~ 14:25$ echo "$strP384" | cut --bytes=1,2,3 ~ 14:25$ strP384='# 27Feb2024 OOPS!!! ^# makes function ignore line - changes wont be made' ~ 14:26$ echo "$strP384" | cut --bytes=1,2,3 # 2 ~ >> OK, works #08********08 #] 26Feb2024 fileops.sh add pth_get_ext() - get extension without fname from pth +-----+ olde code in [fileops.sh - none, fileops run.sh - none, 0_tests/fileops test.sh - none], search pth_get_fNoExt replace pth_get_fnmNoExt # pth_get_fNoExt(pth) - get fNam without extension (NOT pth!) # 23Sep2023 initial pth_get_fNoExt() { path551="$1" fNam551=$( pth_get_fnam "$path551" ) bolPth551=$( echo "$fNam551" | grep "\/" ) if [[ -z "$bolPth551" ]]; then fNoExt551=$( echo "$fNam551" | sed 's|\(.*\)\..*|\1|' ) else fNoExt551="fNam_get_fNoExt error, isPth : $fNam551" fi echo "$fNoExt551" } #08********08 #] 24Feb2024 'pStrPAll_L change.txt' - are [^#, whitespace] lines ignred?? while IFS='' read -r -u 385 strP384; do # screen out [comment, empty] lines # tests if strP has ONE tab - 11Oct2023 needs fix : grep -c -o 'ztbz' or whatever #bolTabInStr=$( echo "$strP384" | sed 's|\x9|ztbz|' | grep -c -o 'ztbz' ) nTab=$( echo "$strP384" | tr \\t \\n | wc -l ) nTab=$(( $nTab - 1 )) if [[ 1 = "$nTab" ]]; then # both of the following are in Cde format (tab=\x9 is NOT translated!) strFnd384=$( echo "$strP384" | sed 's|\x9.*||' ) nStrFnd384=$( grep -c "$strFnd384" "$povr_tmp384" ) if [[ 0 < "$nStrFnd384" ]]; then echo >>"$pLog384" "$nStrFnd384 : $strP384" povr_strP_replace_run "$povr_tmp384" "$strP384" fi fi done 385< "$pStrPtmp384" >> whitespace is taken care of >> ^# is NOT, so add that changed to : while IFS='' read -r -u 385 strP384; do # screen out [comment, empty] lines # tests if strP has ONE tab - 11Oct2023 needs fix : grep -c -o 'ztbz' or whatever # also ignores lines without a tab #bolTabInStr=$( echo "$strP384" | sed 's|\x9|ztbz|' | grep -c -o 'ztbz' ) nTab=$( echo "$strP384" | tr \\t \\n | wc -l ) nTab=$(( $nTab - 1 )) chrOne=$( echo "$strP384" | cut --bytes=1 ) if [ '#' == "$chrOne" ]; then if [[ 1 = "$nTab" ]]; then # both of the following are in Cde format (tab=\x9 is NOT translated!) strFnd384=$( echo "$strP384" | sed 's|\x9.*||' ) nStrFnd384=$( grep -c "$strFnd384" "$povr_tmp384" ) if [[ 0 < "$nStrFnd384" ]]; then echo >>"$pLog384" "$nStrFnd384 : $strP384" povr_strP_replace_run "$povr_tmp384" "$strP384" fi fi fi done 385< "$pStrPtmp384" +-----+ olde code dangerous - just remove from fileops.sh!! : # povrL_strP_replace(bolArXiv bolChrCd povrL strP) sed replace encoded (pStr, povrL) UNTESTED! # [all povrL, strP] are escaped if p[ov, st]Esc961 == 1 # z_Archive each povrL (file listed), strP=(strOld, strNew) # tightly tied to function called, povr_strP_replace : easy to make symbol errors!! # www.BillHowell.ca 02Jun2021 intitial, 05Aug2023 upgrade with chrEncoding # 14Sep2023 inefficient but simple: povrL_pStr[P]_replace keep encoding pStrP with each pOvr # 16Sep2023 handle [no-tab, empty lines in pStrP] # 10Oct2023 pLog384="$d_bin"'bin logs/povrL_pStrP_replace funcFamily pLog.txt' povrL_strP_replace() { date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss") echo >>"$p_log" "$date_ymdhms povrL_strP_replace" bolArXiv961="$1" bolChrCd961="$2" povrL___961="$3" strP____961="$4" # pLog384 ='povrL_pStrP_replace funcFamily pLog.txt', defined in Setup section above # 11Oct2023 missing [check, code]s of [povr, strP, etc] if [ -s "$povrL961" ]; then while IFS='' read -u 961 povr961; do povr_strP_replace_run "$povr961" "$strP____961" done 961<"$povrL___961" else date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss") echo >>"$pLog384" "$date_ymdhms povrL_strP_replace error: povrL doesnt exist : " echo >>"$pLog384" "povrL : $povrL___961" echo >>"$pLog384" '' fi } #08********08 #] 16Feb2024 post changes, run dWeb_get_pHtmWebYesNonL 15:20$ bash "$d_bin"'webSite update local.sh' find all html files /home/bill/web/bin/fileops.sh: line 2914: : No such file or directory extract webPages from htmlL: they have strTst /home/bill/web/bin/fileops.sh: line 1325: : No such file or directory diff: pth_get_dArchive error, OR[no-exist, isP] pth_get_dir error, OR[no-exist, isDir] : /home/bill/web/webWork/pWebYesL.txtfNam_get_fNoExt error, isPth : pth_get_fnam error, OR[no-exist, isDir] /home/bill/web/webWork/pWebYesL.txt archive.fNam_get_ext error, isPth : pth_get_fnam error, OR[no-exist, isDir] /home/bill/web/webWork/pWebYesL.txt: No such file or directory diff: /home/bill/web/webWork/pWebYesL.txt: No such file or directory diff: pth_get_dArchive error, OR[no-exist, isP] pth_get_dir error, OR[no-exist, isDir] : /home/bill/web/webWork/pWebNo_L.txtfNam_get_fNoExt error, isPth : pth_get_fnam error, OR[no-exist, isDir] /home/bill/web/webWork/pWebNo_L.txt archive.fNam_get_ext error, isPth : pth_get_fnam error, OR[no-exist, isDir] /home/bill/web/webWork/pWebNo_L.txt: No such file or directory diff: /home/bill/web/webWork/pWebNo_L.txt: No such file or directory grep: /home/bill/web/webWork/pWebNo_L.txt: No such file or directory ~ pinnL_lineIdx_strTst_split_pYes_pNo() : test # 16Feb2024 test, see 'fileops notes.txt' # 20:39$ line333=$( sed -n '1{p;q}' "$pinn333" ) # pinn333="$d_web"'home.html' # strTst_333=' ~ 20:40$ line333=$( echo "$line333" | cut -c 1-"$strTst_len333" ) ~ 20:40$ echo "$line333" ~ +-----+ >> 1st command OK, 2nd fails! +-----+ 20:44$ echo "$strTst_769"