Bash Scripts
This page provides several
Bash
scripts that I have written over the years.
Many of them are specific to Mac OS X.
See also
my Bash aliases and functions.
-
active_net_iface
Echos the name of the current active network interface (e.g. "en0" or "en1")
-
active_net_service_name
Echos the name of the currently active network service
(e.g. "Airport" or "Built-in Ethernet")
This is the "human-readable" counterpart to the network interface name
that can be obtained via the 'active_net_iface' script.
-
app_running
Determines whether a specified program is running (uses the 'ps' command).
This is intended as an illustration of a technique that might be used in other
scripts - e.g. a script that restarts a program if it gets terminated for some
reason.
-
app_running2
Determines whether a specified program is running.
An alternative version of the above that uses the 'killall -s' command instead
of the 'ps' command.
This version only detects programs running as the current user.
-
fixAppleScriptApp
Changes the application bundle of a compiled AppleScript
(one that has been saved as an application bundle)
so that the application name is used instead of "applet".
Optionally changes the 4-character "creator code" for the application.
-
fus
Uses OS X's "Fast User Switching" to switch to a specified user
or to the login window.
-
grep_pkg
Searches the bom files in /Library/Receipts for a specifed component name
and shows the info about that component from the bom file
followed by the name of the pkg that contained that component.
This is useful for finding out which pkg installed a particular software
component. (See also 'grepl_pkg', 'lspkg', 'pkgsummary')
-
grepl_pkg
Searches the bom files in /Library/Receipts for a specifed component name
and shows the name of the pkg that contained that component.
(The "grepl" in its name refers to "grep -l")
This is useful for finding out which pkg installed a particular software
component. (See also 'grep_pkg', 'lspkg', 'pkgsummary')
-
listjar
Recursively lists the files inside a ZIP, JAR, EAR, or WAR file
-
lspkg
Lists the "bill of materials" for a pkg file.
(See also 'pkgsummary', 'grep_pkg', 'grepl_pkg')
-
make_alias
Makes a Finder-style alias to a specified file or folder
and puts it in the specified destination folder.
-
pkgsummary
Gives a summary of what is contained in a pkg file
according to its "bom" (bill of materials).
(See also 'pkgSummaryOfApps', 'lspkg', 'grep_pkg', 'grepl_pkg')
-
pkgSummaryOfApps
This script gives a summary of what apps from a package
were installed under /Applications or /Applications/Utilities
according to the package's "bom" (bill of materials).
(See also 'pkgsummary', 'lspkg', 'grep_pkg', 'grepl_pkg')
-
remove_suffix
Removes the suffix (portion after the last dot) from strings (e.g. filenames).
Also has a note about how to remove such suffixes from a Bash variable.
-
show_getinfo
Opens the Finder's "Get Info" window for a specified file or folder.
-
indirect_variables
Illustrates how to use "indirect expansion" of Bash variables.