Last active
September 25, 2018 08:04
-
-
Save photonxp/7d26c801c4323f732946426f3fba5dc4 to your computer and use it in GitHub Desktop.
Tag line editing, tag key editing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment