Guest User

Untitled

a guest
Sep 25th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Tag line editing
  4. # Change the line
  5. # from
  6. # vocabulary grammar
  7. # to
  8. # tag:: vocabulary grammar
  9. # Change by given tag value such as "vocabulary" or "grammar"
  10. # Omit the tag line if they already have the key word of "tag"
  11. # Backup your data first if they're important
  12.  
  13. data_dir=/path/to/data_dir
  14.  
  15. tagvalue="vocabulary"
  16.  
  17. tagline_filter="/^tag/!"
  18. tagkey="tag:: "
  19. filtered_operation="s/^\(.*$tagvalue\([[:space:]]\|$\)\)/$tagkey\1/"
  20. sed_directive="$tagline_filter $filtered_operation"
  21. echo "$sed_directive"
  22.  
  23. find_cmd="find $data_dir -maxdepth 1 -type f"
  24.  
  25. for fpath in `$find_cmd`
  26. do
  27. echo $fpath
  28. sed -e "$sed_directive" -i $fpath
  29. done
Add Comment
Please, Sign In to add comment