loading...

Discussion on: What do you use shell scripts for?

Collapse
jcolag profile image
John Colagioia

I do a fair amount of quasi-prototyping using shells, since it's trivial to take repetitious command-line tasks and turn them into a script. I say "quasi," because a lot of the scripts are fine as-is, so I don't convert them to a more typical programming language.

The scripts I currently use regularly are...

  • An "end of day" script that kills my e-mail client, performs a bunch of minor backups of things I'd want immediately in the event of a crash, and take care of some other cleanup tasks.
  • An "overnight" script that does some trivial sleep-tracking (as in I run it when I close my eyes and stop it when I wake up), but it also gives me a simple visual representation of how long it's been running, an on-demand text-to-speech of the current time, a quick note-taking mode, turns the network off/on to prevent notifications, and provides a quick summary of things I need to know for the morning.
  • A script that regenerates my blog (it's a Jekyll static site), including some pre-processing and posting to the open source social networks I use. It also commits the released posts to the git repository, generates the tag pages, and so forth.

I also have a bunch of scripts that coordinate a bunch of small programs, like when I generate my monthly newsletter, since each component is independent (so I don't want them in a combined program, since that's not modular) and it's not worth writing something more complex than "call these in succession and dump the output to the same file before sending it to MailChimp."

Occasionally, something graduates to a (depending on my mood) Ruby or Node script, when the shell code becomes hard to maintain and I need to maintain it, but a lot of it also just stays as-is.