Post shell scripts and other small utility programs.
>Why should you write shell programs?They allow you to do menial tasks in a matter of seconds or add quick fixes to special purpose text data formats (subtitle timing).
Most of my scripts handle filenames, to help with sorting my data collection. I already do most file operations in a terminal, so these were easy to automate.
I just wrote a downloader for a set of wordpress-based manga viewers dependent on readm.org, specifically daomanga.com:
#!/bin/sh
wget -O- $1 | fgrep '"images":' test.html | cut -d ']' -f 1 | cut -d '[' -f 3|tr , '
' | tr -d '\' | xargs wget
The first wget is needed to cope with redirections. Notice the lack of sed or any regular expressions.
My notes are written in a dialect of org markup. This script processes it into troff with ms macros. Normally it only generates line breaks, headings and the titlepage while leaving anything else intact, particularly eqn characters.
When it finds a semicolon, it applies some formatting to the rest of the line. I never use it though.
#!/usr/bin/awk -f
BEGIN {
FS="\n";
}
/^$/ {
print ".sp"; do getline; while($0 == "");
}
/^*/ {
i=index($0, " ");
if(i != 0) {
print ".NH " i-1; print substr($0, i+1); print ".LP";
next;
}
}
/^#\+/ {
i=index($0, " ");
switch(substr($0, 3, i - 3)) {
case "TITLE:":
print ".TL"; print substr($0, i);
break;
case "AUTHOR:":
print ".AU"; print substr($0, i); print ".AB no";
print ".AE"; print ".LP";
}
next;
}
/;/ {
i=(i=index($0, ";") + index(substr($0, i), " "));
split(substr($0, i-1), s, " "); # r=0, ul=1, bl=2
printf("%s", substr($0, 0, i-2)); d=0;
for(i in s) {
f=""; g=""; w=s[i];
switch(substr(w, 0, 1)) {
case "*":
if(a[d] == 2) {
if(--d == 0) f="\\fR";
else if(a[d] == 1) f="\\fI";
}
else {
f="\\fB"; a[+
Post too long. Click here to view the full text.