#!/bin/sh # junker - an example showing stuff that wasn't shown in 'die' # Exit/bailout conditions to clean up afterwards. Needs some work # because it doesn't trap everything perfectly, but I'm too lazy to # fix it. This will trap interrupts, and maybe something else too. trap 'rm $$*.tmp; exit 1' 1 2 # Find all things that begin with the letter A. Remember that case matters! # Then store the results in $$.tmp ls A* > $$.tmp # Print contents of each file given in $$.tmp to stdout for i in `cat $$.tmp` do echo "From file \"$i\":" cat $i echo "" done rm $$.tmp # Don't like what something says? Change it with sed! echo "Original file:" cat Knights echo "" echo "Changed file, after we run it through sed:" cat Knights | sed 's/Nih/Ecky-ecky-ecky-zoobang-neeeeeewonggrumblegrumble...neeeeeewong/' ####### #Afile - #This is a file. Hope this is helpful to everybody that I do all this stuff, because shell scripting isn't #as scary as it really seems. ####### #Anotherfile - #This is another file. You can really do pretty much anything in a loop like this, handy for looping #through a lot of tedious model parameters or fits or something. ####### #Knights #We are the Knights who say Nih! #Knights changes into this, output to stdout: #We are the Knights who say Ecky-ecky-ecky-zoobang-neeeeeewonggrumblegrumble...neeeeeewong!