Advertisement
OldManRiver

Substring position

Jan 2nd, 2020
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.09 KB | None | 0 0
  1. #! /bin/bash
  2. #  Add file to the /Syncs Git Repository
  3. #  Run cmd: bash /Scripts/Git/git-adddbox.sh
  4.  
  5. fstfilt=".dropbox"
  6. secfilt=".git"
  7. trdfilt=".kde"
  8. dboxsrc="/home/files/dbox_dump.txt"
  9. dboxout="/home/files/dbox_redump.txt"
  10. curdir=$PWD;
  11. echo "Working Dir => '$curdir'";
  12. cd /Syncs;
  13. git init;
  14. git config user.name "$USER";
  15. git config user.email "tbotnik@gmail.com"
  16. git branch 'Syncs';
  17. git checkout 'Syncs';
  18.  
  19. while IFS= read -r line
  20. do
  21.     dtmp=${line%%$fstfilt}
  22.     gtmp=${line%%$secfilt}
  23.     ttmp=${line%%$trdfilt}
  24.     dpos=${#dtmp}
  25.     gpos=${#gtmp}
  26.     tpos=${#ttmp}
  27.     echo $dpos $gpos $tpos $line
  28.     if [[ $dpos -eq 0 && $gpos -eq 0  && $tpos -eq 0 ]]; then
  29.         echo $dpos $gpos $tpos $line
  30. #   else
  31. #       git add $line
  32.     fi
  33. done < "$dboxsrc"
  34. cd $curdir;
  35.  
  36. Lines 21-26 do not process correctly according to BASH tutorials, which say they will give the position of the substring in the "linw" variable. I need a surefire way to get the substring position.
  37.  
  38. Wondering if instead of:
  39.  
  40. fstfilt=".dropbox"
  41. secfilt=".git"
  42. trdfilt=".kde"
  43.  
  44. I really need:
  45.  
  46. fstfilt="\.dropbox"
  47. secfilt="\.git"
  48. trdfilt="\.kde"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement