Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Tag line editing
- # Change the line
- # from
- # vocabulary grammar
- # to
- # tag:: vocabulary grammar
- # Change by given tag value such as "vocabulary" or "grammar"
- # Omit the tag line if they already have the key word of "tag"
- # Backup your data first if they're important
- data_dir=/path/to/data_dir
- tagvalue="vocabulary"
- tagline_filter="/^tag/!"
- tagkey="tag:: "
- filtered_operation="s/^\(.*$tagvalue\([[:space:]]\|$\)\)/$tagkey\1/"
- sed_directive="$tagline_filter $filtered_operation"
- echo "$sed_directive"
- find_cmd="find $data_dir -maxdepth 1 -type f"
- for fpath in `$find_cmd`
- do
- echo $fpath
- sed -e "$sed_directive" -i $fpath
- done
Add Comment
Please, Sign In to add comment