Hardware Reference
In-Depth Information
evenifyou'reentirelyhappyremaining inOSX'sgraphicalinterface,shellscriptscanbeyour
friends. They can modify files and folders, perform system functions, and do other sorts of
tricks that are difficult or impossible to perform in other ways (such as using AppleScript
or Automator). In fact, some of my favorite AppleScripts, Automator actions, and Keyboard
Maestro macros rely heavily on embedded shell scripts.
Here are a few things shell scripts can do for you:
• Rename large numbers of files at once
• Modify hidden preferences for OS X and its apps
• Unhide the ~/Library folder in Mountain Lion and later
• Securely delete specific files or folders without first moving them to the Trash
• Force background processes to quit without requiring the use of the Activity
Monitor utility
• Load or unload daemons and agents (see Schedule Any Activity on Your Mac )
Ordinarily, you create and run shell scripts in the Terminal utility (as I show you next).
However, as I mentioned, many of the other utilities I cover in this topic can run shell scripts
too.
Tip: If you'd like to know all about the command line—how to get around, run
programs, edit files, and (of course) work with shell scripts, pick up my book Take
Control of the Mac Command Line with Terminal .
Create Your Own Shell Script
I want to give you a tiny taste of creating your own shell scripts. As with the other topics
in this chapter, I'm not going to teach you anything about programming as such, just the
mechanics of creating and using a simple shell script. I want you to have enough familiarity
with theprocess that youcan successfully reproduce and run shell scripts youmay run across
in magazines, in books, or on Web sites.
You can create and run a shell script in six easy steps.
Step 1: Open Terminal
Open the Terminal utility (in /Applications/Utilities ). You'll be presented with a
mostly blank window. That's where all the magic happens.
Search WWH ::




Custom Search