diff options
author | Matthew Lemon <chaffinach+git@protonmail.ch> | 2022-01-12 15:04:57 +0000 |
---|---|---|
committer | Matthew Lemon <chaffinach+git@protonmail.ch> | 2022-01-12 15:04:57 +0000 |
commit | 3a2d9ce82c2ad74015ea9b5fdbc61df8635b0970 (patch) | |
tree | 86c82cbaf450c5b410c5aac51f1bde011b932708 /grepjournal | |
parent | 5e6e4e80746b2c9fc2c2c1b5684c2658cdecbb96 (diff) |
Working my way to a bash-only solution...
Diffstat (limited to '')
-rwxr-xr-x | grepjournal | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/grepjournal b/grepjournal index db34e0e..83e7003 100755 --- a/grepjournal +++ b/grepjournal @@ -31,8 +31,22 @@ printf "=%.0s" $(seq $termsize) echo "" # subsitute to get the right format using sed -sed -r -i 's/\/home\/lemon\/Notes\/journal\/([[:digit:]]*-[[:digit:]]*-[[:digit:]]*)\.md:-[[:blank:]](.*)/\1 \2/' "$tmpfile" +# TODO this to be replaced +re='^/home/lemon/Notes/journal/([0-9]*[0-9]*)-([0-9]*[0-9]*)-([0-9]*[0-9]*)\.md: - ([0-9]*[0-9]*-[0-9]*[0-9]*)(.*)' +while IFS= read -r line; do + if [[ $line =~ $re ]]; then + year=${BASH_REMATCH[1]} + echo "$year" + month=${BASH_REMATCH[2]} + echo "$month" + day=${BASH_REMATCH[3]} + echo "$day" + note=${BASH_REMATCH[4]} + echo "$note" + fi +done < "$tmpfile" +#sed -r -i 's/\/home\/lemon\/Notes\/journal\/([[:digit:]]*-[[:digit:]]*-[[:digit:]]*)\.md:-[[:blank:]](.*)/\1 \2/' "$tmpfile" # output -cat "$tmpfile" | sort +# cat "$tmpfile" | sort |