Something like victory
In this file, I would like to create a number of natural line breaks, which I will then make go away by some simple command. I hope to be able to i) compose text with line breaks, then ii) run a script on that text to make it postable through a Blogger API (or something), even though I do not remember what API stands for.
Also: I'd like to preserve double line breaks, as occurs between this fake paragraph and the previous one.
#!/bin/sh
# txt2blog.sh - translates auto-filled plain text (possibly with hyperlinks) into a single, blog-ready line with (angle-bracket p angle-bracket) tags and everything
basename=$(echo $1 | sed 's/\..*//')
echo "Basename of $1 is $basename"
echo "Removing /tmp/$basename.txt"
rm /tmp/$basename.txt
echo "Creating /tmp/$basename.txt"
touch /tmp/$basename.txt
echo "(angle-bracket p angle-bracket)" >> /tmp/$basename.txt
cat $1 >> /tmp/$basename.txt
echo "(angle-bracket slash p angle-bracket)" >> /tmp/$basename.txt
cat /tmp/$basename.txt | sed 's/^$/(backslash angle-bracket backslash slash p backslash angle-bracket backslash angle-bracket p backslash angle-bracket)/g' | while read line ; do echo -n "$line " ; done | sed 's/(backslash angle-bracket p backslash angle-bracket [backslash angle-bracket backslash slash p backslash angle-bracket backslash angle-bracket p backslash angle-bracket]+/backslash angle-bracket p backslash angle-bracket/g' > $basename.blog
echo "Here is the blog-ready file:"
echo ""
cat $basename.blog
Labels: infrastructure, script
0 Comments:
Post a Comment
<< Home