When we find ourselves doing something very difficult, automating the task records what we've done. When we do it in the future, it will be easier. This is how we build up our little bag of tricks.
Sometimes it takes hours to work out exactly the right command required to do something. For example, there is a program that creates ISO images, the kind you burn onto CD-ROMs. Its manual page describes hundreds of options, but to make an image readable by Windows, Unix, and Mac systems, the command is simply:
mkisofs -D -l -J -r -L -f -P "
" -V "
Sure, you can do it from a GUI, but where's the fun (or ability to script) in that?
This command also lets you do things not found in most GUIs, such as the ability to specify a copyright note, author name, and so on.
This is a good example of something to work into a .BAT file (DOS) or a Unix/Linux shell script.
Here's a shell script called makeimage1 that uses this:
#!/bin/bash mkisofs -D -l -J -r -L -f -P "Limoncelli" -V 'date -u +%m%d' $*
'date -u +%m%d' sets the
volume name to the current date.
One of the things that held me back from writing good scripts was that I didn't know how to process command-line parameters. Here are instructions for copying all the command-line arguments into a script.
$* in the makeimage1 script means "any items on the
command line." So, if you typed:
makeimage1 cdrom/ ...