An update to the bash script that takes a parameter:

#!/bin/bash

book=$1

[[ -z $book ]] && { echo “No argument supplied, exiting!”; exit 1; }

[[ ! -e $book ]] && { echo “Can’t find a file with the name $book, exiting”; exit 1; }

title=${book%.*}
bookcounter=0
linecounter=0
sed -i ‘s/\r$//’ “$book”
while read line
do
((linecounter+=1))
if [[ $linecounter -gt 300 && -z “$line” || -z “$output_file” ]]; then
linecounter=0
((bookcounter+=1))
formatted_bookcounter=$(printf “%03d” $bookcounter)
output_file=”${title}${formatted_bookcounter}.txt”
echo “…starting segment $output_file”
echo “$title – segment $formatted_bookcounter” > $output_file
echo “===================” >> $output_file
echo “” >> $output_file
fi
echo “$line” >> $output_file
done < "$book"

Why are we always trying to copy Windows?

There are skins for each of the OSs that aren’t Windows–to make them LOOK like Windows.

http://linux.slashdot.org/story/10/08/26/199228/Making-Ubuntu-Look-Like-Windows-7

There’s the latest; why is everyone trying so hard? There’s the usual answer; the more you make OSS look like proprietary software, the more likely that n00bs will give it a shot–but does this turn you off of the individualistic nature of OSS?

Get emailed a portion of classic literature each day.

Ok, so I am feeling guilty over not reading enough GOOD books.

So, I devised a cunning plan whereby I am emailed a portion of a classic book each day. I started with the Iliad. I know that I’ll clear my emails every single day because a cluttered inbox irritates me…so this is the perfect motivational tool. I wrote each of these scripts (with occasional help from the lovely folks who hang out with me in Programming Talk at the Ubuntu Forums), and this is the way I did this.

(1) Download a book you want to read. I suggest starting with something like the Iliad or Ovid’s Metamorphoses. Poetry is a great way to start; it’s episodic and fun. Head to Gutenberg.org to find text versions of any book you want. Other suggestions: the Aeneid, any Shakespeare play, the Divine Comedy, Paradise Lost, etc.

(2) Drop it into a folder, renaming it ‘[whatever].txt’. In my example, I’m dividing the Metamorphoses.

(3) Navigate to
that folder at the CL.

(4) Run this script to divide the book up into 300 line segments (or, if there is no paragraph break at 300 lines, the script will add more lines until a paragraph break is reached. That way, you don’t end up getting half a soliloquy). Obviously, if you want to read more or less each day, change the number of lines to however much you want:


#!/bin/bash
bookcounter=0
linecounter=0
sed -i 's/\r$//' metamorphoses.txt
while read line
do
((linecounter+=1))
if [[ $linecounter -gt 300 && -z "$line" || -z "$output_file" ]]; then
linecounter=0
((bookcounter+=1))
formatted_bookcounter=$(printf "%03d" $bookcounter)
output_file=metamorphoses${formatted_bookcounter}.txt
echo "...starting segment $output_file"
echo "Metamorphoses - segment $formatted_bookcounter" > $output_file
echo "===================" >> $output_file
echo "" >> $output_file
fi
echo "$line" >> $output_file
ndone < metamorphoses.txt


(5) In your folder, delete the big file. You should now have several (or possibly several dozen or hundreds) of much smaller files, numbered consecutively.

(6) Then, run this script (Adds a subject header to each of the files in your folder) :


#!/bin/bash
FILES="*"
for f in $FILES ; do
sed -i '1s/^/Subject:Your Daily Book Part, Tarah.\n/' "$f"
cat "$f"
done


(7) Then, add this script to wherever you store your scripts. It sorts the files in your pet directory by number, gets the first one (i.e. 'metamorphoses024.txt') mails it to you, then deletes that file. Then, the next time the script is run, it will get 'metamorphoses025.txt' as the first file in the directory. Call it 'bookmailer.sh' or whatever. NB: you must have msmtp installed to make this work. Ensure it's reachable through your path. Any other command line emailer will also work; I know how to use msmtp, so that's what I do. Plus, I use
Kubuntu, so it's available at the repos.


#!/bin/bash
cd /home/tarahmarie/Documents/MyEbooks/aaa/
FILE=$(ls | sort -n | head -1)
cat $FILE | msmtp -a gmail youremailaddress@gmail.com
\rm `ls | sort -n | head -1`


(8) Execute 'bookmailer.sh' at the CL to ensure it works. If, in a few seconds, you get an email containing the subject line 'Your Daily Book Part, WhoeverYouAre', then the command is working. If you're having any problems, ensure that you have permissions to each of these scripts, and that they're marked 'executable'.

(9) Add 'bookmailer.sh' to your system's list of scheduled commands. I use kcron, so I set 'bookmailer.sh' to be executed each day at 8AM.

(10) Feel superior to other humans for the fact that you're reading a 'good' book every day. This is DEFINITELY how I'm going to get all the way through War and Peace. Eventually. Let us not even speak of Remembrance of Things Past. I will CONQUER you, Proust, ole buddy.

The best ebook format.

I’m transferring most of my fantasy and science fiction to digital versions. There’s a sort of sadness involved with doing so; these books have been my friends for decades, and I love them.

Still, there’s something to be said for NOT spraining my thumb trying to hold the latest Goodkind or Jordan or Silverberg hardcover in the bathtub.

I’m going with a Nook, and I’m building an ebook library of epubs, since it’s an open format with OSS tools at the CL for conversion and maintenance.

After all the preaching I’ve done, I should be the first to acknowledge that content and means of distribution are NOT the same thing…but there’s a hint of sadness as I sell my copies of the Feist/Wurts Empire trilogy. I love the cover picture on Servant of the Empire; it’s AWESOME.

I’ll miss the books…but not while I’m moving, not on the airplane, not when I’m decorating, not in the bathtub…wait.
Why didn’t I do this before?

And does anyone know how to get a copy of that cover as a poster?