diff options
[hooks] Reworked generate hooks to use a string of all files to work on, rather than having to find it
1 files changed, 2 insertions, 2 deletions
| -rwxr-xr-x | generate-hooks/make-titles.sh | 4 |
diff --git a/generate-hooks/make-titles.sh b/generate-hooks/make-titles.sh index bf739ff..1c9ebef 100755 --- a/generate-hooks/make-titles.sh +++ b/generate-hooks/make-titles.sh @@ -1,18 +1,18 @@ #!/bin/bash if [ -z "$1" ]; then - echo First parameter must be a path + echo First parameter must be string with file paths exit fi # Loop through all HTML files in given directory -for file in $(find "$1" -type f -name "*.html"); do # Get text that matches "h1>any amount of characters</h1" from current file # remove the "h1>" and "</h1" from result title=$(egrep -o "h1(.+)>(.+)<\/h1" $file | sed "s/h1[^>]\+>\|<\/h1//g") # Escape all non-acceptable characters (thanks https://www.unix.com/302989284-post3.html) title=$(echo $title | sed 's/[^a-zA-Z 0-9]/\\&/g') +for file in $1; do # Replace all "[TITLE]" text in current file with what we selected (inside title) sed -i "s/\[TITLE\]/$title/g" $file |