Using AppleScript to automate tasks with Terminal
You can use AppleScripts with Terminal to save time or to automate redundant tasks. Terminal is a scriptable application and it responds to a few special AppleScript commands. These commands are described in detail in Terminal's AppleScript dictionary.
The Do Script command can be used to send a UNIX or shell script command to Terminal.
To view Terminal's AppleScript dictionary:
Drag the Terminal icon onto the Script Editor icon, located in the /Applications/AppleScript folder.
For more information about AppleScript, see the AppleScript website.
For an example of the type of AppleScripts you can use with Terminal, see the AppleScript scriptable applications website.