diff options
author | Jefferson Julio <[email protected]> | 2021-05-30 20:06:28 -0300 |
---|---|---|
committer | Jefferson Julio <[email protected]> | 2021-05-30 20:06:28 -0300 |
commit | e9c35a9eff9e0881df7d6a6e8d17b70ac37ad0fe (patch) | |
tree | 2a6a9d105b68daea1094e5a2faaca0fb9b138ab3 /utils/parse-article.sh | |
parent | 1d628ce8cee397ca9c2a8a27d5820c91812a27ca (diff) | |
download | blog.sh-e9c35a9eff9e0881df7d6a6e8d17b70ac37ad0fe.tar.bz2 blog.sh-e9c35a9eff9e0881df7d6a6e8d17b70ac37ad0fe.zip |
Better modularization
Diffstat (limited to 'utils/parse-article.sh')
-rwxr-xr-x | utils/parse-article.sh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/utils/parse-article.sh b/utils/parse-article.sh new file mode 100755 index 0000000..c3e540a --- /dev/null +++ b/utils/parse-article.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +ARTICLE_TITLE=$(basename "$ARTICLE_FILE") + +# Pick all file content +ARTICLE_FILE_CONTENT=$(cat "$ARTICLE_FILE") + +# The first 3 lines of the file are metadata information +ARTICLE_METADATA=$(echo "$ARTICLE_FILE_CONTENT" | head -n 3) + +# Skip file metadata, first 3 lines +ARTICLE_CONTENT=$(echo "$ARTICLE_FILE_CONTENT" | tail -n +3) + +# Tags are placed on the first line of the file, delimited by commas +IFS=',' read -ra ARTICLE_TAGS <<< "$(echo "$ARTICLE_METADATA" | head -n 1)" + +ARTICLE_TIME=$(stat --format="Criado em: %w<br/>Última atualização: %z" "$ARTICLE_FILE") +ARTICLE_BYTES=$(stat --format="%s bytes" "$ARTICLE_FILE") |