Mere
aggregation:
Collecting output from separate
utilities
disk_info shell script (source)
(OUTPUT)
simple commands
can be on same line, separated by “;”
for loop
loop variable
simple list of values for loop variable
variable substitution: $d
shell replaces a placeholder with a value or result
command substitution
for p in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
`seq
1 15` or $(seq 1 15)
utility program "seq"
provides list values 1 to 15
provides a value for
variable $lbl
often used to provide command arguments
Simplify
an interface
ps2booklet shell script (source)
(OUTPUT)
problem: creating a booklet document (“imposition”)
psutils package provides tools
psbook — re-order pages
pstops — arbitrary page placement
commands are very simple
psbook <input file> | pstops -p<paper size> <layout>
syntax of <layout> is very difficult to work with
'2:0L(8.5in,0)+1L(8.5in,5.5in)' (DIAGRAM)
simple if / then
test, aka [
case
installation: provide several names for one script
Custom
utility program
tok(ens) Perl script (source)
Example: extract image file names from an HTML file:
“Shebang” tells system how to execute this file (which program will interpret the text)
Advantages:
More powerful and convenient language syntax
Better performance
Disadvantages:
Less portable (requires interpreter and libraries installed)
Output
munging
dur Perl script (source) (OUTPUT) (DIAGRAM)
sndfile-info output
is too verbose and not in convenient format.