I’ve been coding off and on in a number of different languages (around seven by my count) since I got my first graphing calculator back in 1999, but I’d never written a shell script before today. I mean, yes, I’d copied other people’s shell scripts from the internet when it’s suited me, but I’d never written my own before.
That all changed today when I was reading an article in Scientific American on the subject of internet comment threads. In the article, the author mentions the concept of disemvoweling trolls, which struck me as a good thing to automate. Thus, my first shell script was born.
I’ll give you the code in a moment, but before I do, in debugging the program (who would have thought that you needed to debug two lines of code?), I learned something useful: when writing shell scripts, your variable names should not have trailing whitespace before the = or they will not be seen as variables (something that will take some adjusting to for me, since aesthetically I prefer to have whitespace surrounding my equals signs). Maybe I should have twigged that something was off when Vim didn’t turn my variable a different color when I initialized it, but I’m new to this, so give me a break.
And now, the script (well commented and maybe not as elegant as it could be, but, again, it’s my first time, so give me a break):
# This script will disemvowel its input and feed it into a new file
# Create a disemvoweled version of the file being read
# Disemvowel file with sed and feed into new file
sed -e 's/[AEIOUaeiou]//g' $1 >> "$DSMVLD"
Of course, I could easily make it so this could to batch disemvowelment, butI can always do that later if I actually see the need to disemvowel more than a few files at a time.
If you want and if you can, feel free to share your first scripts, or any fun scripts you’ve written in the comments.