-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.sh
executable file
·43 lines (38 loc) · 1.06 KB
/
create.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
writeToFile () {
echo $1 >> event.txt
echo "" >> event.txt
}
first_post=true
# create file with event date as first line of text
writeToFile "$(date +%A) assorted links:" > event.txt
# add posts
cat posts.json | jq '.[] | select(.shared=="yes") | .href, .description, .extended, .tags' | \
while read -r h; read -r d; read -r e; read -r t; do
# remove quotes from strings and substitute '\n' with newlines
desc=$(echo $d | tr -d \" | sed 's/\\n/\n/g')
info=$(echo $e | tr -d \" | sed 's/\\n/\n/g')
link=$(echo $h | tr -d \")
tags=$(echo $t | tr -d \")
# add post separator unless is first post
if [ "$first_post" = true ]; then
first_post=false
else
writeToFile "---"
fi
# add post description
writeToFile "$desc"
# add extended info if present
if [ -n "$info" ]; then
writeToFile "$info"
fi
# add tags if present (ex: #bitcoin #nostr)
# tagline=""
# if [ -n "$tags" ]; then
# for tag in $tags; do tagline+="#$tag "; done
# writeToFile "$tagline"
# fi
# add link
writeToFile "🔗 $link"
done
cat event.txt