<?xml version="1.0" encoding="iso-8859-1"?>

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>macosxhints.com Unix tips and tricks</title>
<link>http://hints.macworld.com/index.php?topic=unix</link>
<description>Unix tips and tricks from macosxhints.com</description>
<managingEditor>webteam@macosxhints.com</managingEditor>
<webMaster>webteam@macosxhints.com</webMaster>
<copyright>Copyright 2014 Mac OS X Hints</copyright>
<generator>Geeklog</generator>
<pubDate>Wed, 15 Jan 2014 07:00:01 -0800</pubDate>
<language>en-gb</language>
<atom:link href="http://hints.macworld.com/backend/hintsunix.rss" rel="self" type="application/rss+xml" />
<item>
<title>Move the Terminal cursor position with the mouse</title>
<link>http://hints.macworld.com/article.php?story=20140114080042155</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20140114080042155</guid>
<pubDate>Wed, 15 Jan 2014 07:00:00 -0800</pubDate>
<comments>http://hints.macworld.com/article.php?story=20140114080042155#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>Which Terminal gurus among us hasn't wasted too many minutes to count arrowing around the manipulate the cursor while deep within the confines of the command line?&lt;br /&gt;
&lt;br /&gt;
The Terminal gurus who know this trick, I guess: Hold down the Option key and click where you'd like the cursor to move, and Terminal rushes the cursor that precise spot.&lt;br /&gt;
</description>
</item>
<item>
<title>Bash Function to open man pages in new terminal window</title>
<link>http://hints.macworld.com/article.php?story=20131226153018801</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20131226153018801</guid>
<pubDate>Mon, 30 Dec 2013 06:30:00 -0800</pubDate>
<comments>http://hints.macworld.com/article.php?story=20131226153018801#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>&lt;p&gt;When I'm stumbling around the command line, I usually need to keep various man pages open for reference. I always forget I can get a dedicated man window from the Help or Contextual menus. This bash function allows you to open a man page in a new window directly from the command line.&lt;/p&gt;&lt;p&gt;&lt;pre&gt;&lt;code&gt;function man { if &amp;#91; &amp;amp;#36;# -eq 1 &amp;#93; ; then open x-man-page://&amp;amp;#36;1 ; elif &amp;#91; &amp;amp;#36;# -eq 2 &amp;#93; ; then open x-man-page://&amp;amp;#36;1/&amp;amp;#36;2 ; fi }&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;&lt;p&gt;Just put this function in your .bashrc file, and when you use the man command, the information opens in Terminal's Man Page specific window setting style. If you don't want to override the default 'man' command operation, you can change the function name to something else.&lt;/p&gt;&lt;p&gt;This function expands on OS X's &lt;a href=&quot;http://hints.macworld.com/article.php?story=20031225072602242&quot;&gt;x-man-page url scheme&lt;/a&gt;. And of course, there are plenty of alternate ways to view man pages such as  ...&lt;/p&gt;</description>
</item>
<item>
<title>Prevent a Mac from sleeping from the command line </title>
<link>http://hints.macworld.com/article.php?story=20130620032443758</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20130620032443758</guid>
<pubDate>Mon, 24 Jun 2013 07:30:00 -0700</pubDate>
<comments>http://hints.macworld.com/article.php?story=20130620032443758#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>We've run a number of hints about preventing a Mac from sleeping, such as &lt;a href=&quot;http://hints.macworld.com/article.php?story=20070730152621442&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;http://hints.macworld.com/article.php?story=20120801003744629&quot;&gt;this&lt;/a&gt;. &lt;br&gt;&lt;br&gt; I came across another really simple way to do this, using the &lt;tt&gt;pmset&lt;/tt&gt; command. Just run this command in terminal:&lt;br&gt;&lt;br&gt; &lt;tt&gt;pmset noidle&lt;/tt&gt;   &lt;br&gt;&lt;br&gt; Terminal will display the following text:&lt;br&gt;&lt;br&gt; &lt;tt&gt;Preventing idle sleep (^C to exit)...&lt;/tt&gt; &lt;br&gt;&lt;br&gt; To allow the Mac to go back to sleep, according to its current Energy Saver settings, just press Control-C.
</description>
</item>
<item>
<title>Peek inside zip archives from Terminal </title>
<link>http://hints.macworld.com/article.php?story=20130611004823949</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20130611004823949</guid>
<pubDate>Wed, 12 Jun 2013 07:30:00 -0700</pubDate>
<comments>http://hints.macworld.com/article.php?story=20130611004823949#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>Have you ever wanted to see what's in a Zip archive without unzipping it? Well, it turns out that there is a Terminal command you can use to do so: &lt;tt&gt;zipinfo&lt;/tt&gt;. Just run &lt;tt&gt;zipinfo [filename]&lt;/tt&gt; to get a list of files in an archive. &lt;br&gt;&lt;br&gt;There are a number of interesting options to this command. The default behavior is to list the files in a short &quot;ls -l&quot; format, but you can also use the &lt;tt&gt;-m&lt;/tt&gt; or &lt;tt&gt;-l&lt;/tt&gt; options to have medium or long lists. You can use the &lt;tt&gt;-1&lt;/tt&gt; option to only show file names. And there are other useful options in the &lt;tt&gt;man zipinfo&lt;/tt&gt; page.&lt;br&gt;&lt;br&gt; One other useful item is the amount of space the archive takes up, and the amount of space saved. For example:&lt;br&gt;&lt;br&gt;&lt;tt&gt;12 files, 10587791 bytes uncompressed, 9400060 bytes compressed:  11.2%&lt;/tt&gt; &lt;br&gt;&lt;br&gt; It's worth noting that this command has been around for a long time, and I was surprised to find that it's not mentioned here. 
</description>
</item>
<item>
<title>Find users that use the most disk space</title>
<link>http://hints.macworld.com/article.php?story=20130404072518701</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20130404072518701</guid>
<pubDate>Thu, 11 Apr 2013 07:30:00 -0700</pubDate>
<comments>http://hints.macworld.com/article.php?story=20130404072518701#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>Find which users take up the most disk space. This can of course be used to indentify any number of users so I picked 10 as an arbitrary number.&lt;br&gt;&lt;br&gt;If you are already root (unlikely, but possible) you can remove the &lt;code&gt;sudo -s&lt;/code&gt; part.  Here's the command: &lt;div style=&quot;margin-left: 20px; margin-top:10px; margin-bottom:10px; padding: 5px; border:1px solid; width:520px; height:60px; overflow:scroll;white-space:nowrap;resize:both&quot;&gt;&lt;pre&gt;sudo -s du -sm /Users/* | sort -nr | head -n 10&lt;/pre&gt;&lt;/div&gt;Generally you would have to make sure that you use &lt;code&gt;sudo -s&lt;/code&gt; or it will give a few Permission denied errors before finally spitting out the results, and they may be incorrect. The directory structure should start with the &lt;i&gt;/Users&lt;/i&gt; Directory and then it will recursively perform the operation. This may miss any folders outside of the normal user space, but there shouldn't normally be any user data there.&lt;br&gt;&lt;br&gt;[&lt;b&gt;crarko adds:&lt;/b&gt; I tested this, and it works as de ...</description>
</item>
<item>
<title>Flatten a directory structure </title>
<link>http://hints.macworld.com/article.php?story=20130224223337451</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20130224223337451</guid>
<pubDate>Tue, 26 Feb 2013 07:30:00 -0800</pubDate>
<comments>http://hints.macworld.com/article.php?story=20130224223337451#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>There may be times when you want to consolidate all the files in a directory and its sub-directories (or a folder and its sub-folders) into a single directory or folder. For example, you may have a folder with sub-folders for years, and other sub-folders in each year folder for months, and you may want to move files in the month folders all to the top level. &lt;br&gt;&lt;br&gt;Doing this manually is a complex and time-consuming process. While you might be able to do this by using a search - for example, if all the files are, say, Excel files, you can search for Excel files in the top folder, then just copy them all to a new folder - if there are lots of different types of files, this wouldn't make things easier.&lt;br&gt;&lt;br&gt;Fortunately, there's a way to do this from a command line. On the &lt;a href=&quot;http://www.bedroomlan.org/coding/flatten-directory-structure&quot;&gt;BedroomLAN&lt;/a&gt; blog, Alexios presents two commands that will do this:&lt;br&gt;&lt;br&gt; &lt;tt&gt;cd &amp;#36;ROOT_DIRECTORY&lt;br&gt;find -type f -print0 | xar ...&lt;/tt&gt;</description>
</item>
<item>
<title>Extract names and emails from a text file</title>
<link>http://hints.macworld.com/article.php?story=20130219161025495</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20130219161025495</guid>
<pubDate>Wed, 20 Feb 2013 07:30:00 -0800</pubDate>
<comments>http://hints.macworld.com/article.php?story=20130219161025495#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>I have a recurring need to extract full names and email addresses from a plaintext archive of email messages. The archive is created by selecting a bunch of emails in Mail, copying them, pasting into TextEdit, and converting to plain text.&lt;br&gt;&lt;br&gt;For each message in the file, the first line contains the information I wanted:&lt;pre&gt;From: Joe Example &amp;lt;joe@example.com&amp;gt;&lt;/pre&gt;I wanted one email address per line, suitable for pasting into another location. I am far from an expert with the &lt;tt&gt;bash&lt;/tt&gt; shell, but here's what I came up with—I imagine there are many more efficient ways to do this, as I'm sure experienced &lt;tt&gt;perl&lt;/tt&gt;, &lt;tt&gt;sed&lt;/tt&gt;, &lt;tt&gt;awk&lt;/tt&gt;, etc. users may point out. Note that this is highly dependent on the format created by Apple's Mail app in OS X 10.8.&lt;br&gt;&lt;br&gt;&lt;tt&gt;grep 'From:' /path/to/archive.txt | cut -f2 -d&amp;#092;&amp;lt; | cut -f1 -d&amp;#092;&amp;gt; | pbcopy&lt;/tt&gt;&lt;br&gt;&lt;br&gt;The &lt;tt&gt;grep&lt;/tt&gt; bit pulls out the entire &lt;tt&gt;From:&lt;/tt&gt; line, then the first &lt;tt&gt;cut ...&lt;/tt&gt;</description>
</item>
<item>
<title>Control the Finder with the Terminal</title>
<link>http://hints.macworld.com/article.php?story=20121031111929732</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20121031111929732</guid>
<pubDate>Thu, 13 Dec 2012 07:30:00 -0800</pubDate>
<comments>http://hints.macworld.com/article.php?story=20121031111929732#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>There are several ways to open a Terminal window to the current directory in the Finder. But wouldn't it be useful if you could do the reverse and open a Finder window to the current Terminal directory? Well, you can, and you can completely control the Finder from the terminal.&lt;br&gt;&lt;br&gt; I have put the code on &lt;a href=&quot;https://github.com/NapoleonWils0n/bashfinder&quot;&gt;github&lt;/a&gt; with full instructions on how to set it up. It works by using bash_completion, .bash_profile with some applescript to control the Finder, .inputrc and .bash_aliases.&lt;br&gt;&lt;br&gt; Here are some of the features:&lt;ul&gt;	&lt;li&gt;Changing a directory in the Terminal opens the same directory in the Finder.&lt;/li&gt;	&lt;li&gt;You can change the Finder window view from the Terminal (column, list, icon views).&lt;/li&gt;	&lt;li&gt;It is case insensitve, you can press Tab for menu completion, and Shift-Tab to expand bash aliases.&lt;/li&gt;	&lt;li&gt;Open a Terminal directory to the current Finder window.&lt;/li&gt;&lt;/ul&gt;This code will work with both the Terminal ...</description>
</item>
<item>
<title>See how long a given process has been running</title>
<link>http://hints.macworld.com/article.php?story=20121127064752309</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20121127064752309</guid>
<pubDate>Wed, 28 Nov 2012 07:30:00 -0800</pubDate>
<comments>http://hints.macworld.com/article.php?story=20121127064752309#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>I wanted to find out how long a certain background process had been running. There's a column for CPU Time in Activity Monitor, but that's not real clock time.&lt;br&gt;&lt;br&gt; It turns out you can get this information with &lt;tt&gt;ps&lt;/tt&gt;, via the &lt;tt&gt;etime&lt;/tt&gt; keyword. So to get a list of every running process, in decreasing order of run time, just use this command:&lt;pre&gt;ps -ax -o etime,command -c&lt;/pre&gt;To see the results for a single process, just add a &lt;tt&gt;grep&lt;/tt&gt; at the end for the process' name. For example:&lt;pre&gt;&amp;#36; ps -ax -o etime,command -c | grep AppleVNCServer03-08:09:16 AppleVNCServer&lt;/pre&gt;So on my Mac, the &lt;tt&gt;AppleVNCServer&lt;/tt&gt; has been running for three days, eight hours, nine minutes, and 16 seconds. I have a need to do this pretty regularly, so I turned it into a simple command line app:&lt;pre&gt;#!/bin/bash# Display the time a given process has been running# Use the process name when calling the commandps -ax -o etime,command -c | grep &amp;#36;1&lt;/pre&gt;I saved tha ...</description>
</item>
<item>
<title>See details of an app's virtual size</title>
<link>http://hints.macworld.com/article.php?story=20121016063646746</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20121016063646746</guid>
<pubDate>Fri, 19 Oct 2012 07:30:00 -0700</pubDate>
<comments>http://hints.macworld.com/article.php?story=20121016063646746#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>If you use &lt;tt&gt;top&lt;/tt&gt; in Terminal, you may occasionally see apps with &lt;b&gt;huge&lt;/b&gt; &lt;tt&gt;VSIZE&lt;/tt&gt; values. I know this because Witch, one of our apps, is an example of such&amp;mdash;it's &lt;tt&gt;VSIZE&lt;/tt&gt; can exceed 11GB.&lt;br&gt;&lt;br&gt;In trying to figure out why this was so (short answer seems to be: we can't control it, but it's not a problem), I ran across an interesting command, &lt;tt&gt;vmmap&lt;/tt&gt;. This command will spew out a &lt;b&gt;ton&lt;/b&gt; of detail about virtual memory usage. Stringing a couple Unix commands together, though, you can extract just the summary portion of the report.
In Terminal, run this command:&lt;pre&gt;&lt;code&gt;vmmap -resident PID# | grep &quot;Summary for&quot; -A 999&lt;/code&gt;&lt;/pre&gt;Replace &lt;tt&gt;PID#&lt;/tt&gt; with the process ID you're interested in observing, and you'll get a nice summary of its virtual memory state. You can see what's virtual, and what's actually resident. Here's a bit of the output for Witch, for example:&lt;pre&gt;&lt;code&gt;...REGION TYPE                      VIRTUAL RESIDENT====== ...&lt;/code&gt;&lt;/pre&gt;</description>
</item>
<item>
<title>Quickly eject all disks from the command line </title>
<link>http://hints.macworld.com/article.php?story=20120901094847629</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20120901094847629</guid>
<pubDate>Wed, 05 Sep 2012 07:30:00 -0700</pubDate>
<comments>http://hints.macworld.com/article.php?story=20120901094847629#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>Instead of using the following to eject all disks:&lt;pre&gt;osascript -e 'tell &quot;Finder&quot; to eject (every disk)' &lt;/pre&gt;I've found that this is much faster:&lt;pre&gt;find /Volumes -maxdepth 1 -not -user root -print0 | xargs -0 diskutil eject &lt;/pre&gt;Run this command from Terminal, or in a shell script, to eject all your local disks.&lt;br&gt;&lt;br&gt; To eject network volumes, this code works:&lt;pre&gt;find /Volumes -maxdepth 1 -not -user root -print0 | xargs -0 umount &lt;/pre&gt; [&lt;b&gt;kirkmc adds&lt;/b&gt;: The problem with this hint is that each line of code works for different types of volumes. If you have both local and network volumes, you need to use both; you could, of course, stick them together with a semi-colon separating them so they are, in effect, a single command.. In my tests, it's not really faster than the &lt;tt&gt;osascript&lt;/tt&gt; code above, but I'm posting it because some may find it useful. If you have different results in speed or efficacy, please post in the comments.] 
</description>
</item>
<item>
<title>Send Terminal output to iCloud </title>
<link>http://hints.macworld.com/article.php?story=201208200006343</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=201208200006343</guid>
<pubDate>Tue, 21 Aug 2012 07:30:00 -0700</pubDate>
<comments>http://hints.macworld.com/article.php?story=201208200006343#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>Imagine that you run a script automatically on your Mac, and that you want to check the result of that script. There are many ways you could do this, such as remotely connecting to the Mac, or sending the results by e-mail. But with iCloud, you can also save the output to a file and put it on iCloud, where you can access it with your favorite iCloud-compatible text editor on another Mac, or on an iOS device.&lt;br&gt;&lt;br&gt; To do so, simply send the output of the script to a file like this:&lt;br&gt;&lt;br&gt; &lt;tt&gt;~/Library/Mobile&amp;#092; Documents/com&amp;#092;~apple&amp;#092;~TextEdit/Documents/filename.txt&lt;/tt&gt;&lt;br&gt;&lt;br&gt; So, to save a list of a directory's contents, you'd use this:&lt;br&gt;&lt;br&gt; &lt;tt&gt;ls -al &gt; ~/Library/Mobile&amp;#092; Documents/com&amp;#092;~apple&amp;#092;~TextEdit/Documents/list.txt&lt;/tt&gt; &lt;br&gt;&lt;br&gt; That saves a file called list.txt in TextEdit's Documents folder. Look inside the ~/Library/Mobile&amp;#092; Documents folder for the paths to other apps you have that can use iCloud. Each folder in the Mobile  ...</description>
</item>
<item>
<title>Command-drag to Terminal to change directory </title>
<link>http://hints.macworld.com/article.php?story=20120726193230711</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20120726193230711</guid>
<pubDate>Mon, 30 Jul 2012 07:30:00 -0700</pubDate>
<comments>http://hints.macworld.com/article.php?story=20120726193230711#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>If you hold down the Command key while dragging an icon to a Terminal window, it will &lt;tt&gt;cd&lt;/tt&gt; to either the directory you dragged (if it's a folder) or the directory containing the item you dragged (if it's a file). &lt;br&gt;&lt;br&gt; I don't know when this feature appeared; it might not be specific to 10.8, but that's where I discovered it.&lt;br&gt;&lt;br&gt; [&lt;b&gt;kirkmc adds&lt;/b&gt;: This is a really neat feature. Also, if you Command-drag an application or other bundle, Terminal will &lt;tt&gt;cd&lt;/tt&gt; to inside that bundle. This is great if you need to access files within an application bundle, for example. The comments are saying that this is indeed 10.8 only.]
</description>
</item>
<item>
<title>Script to delete huge sparsebundle images</title>
<link>http://hints.macworld.com/article.php?story=20120709152257934</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20120709152257934</guid>
<pubDate>Thu, 19 Jul 2012 07:30:00 -0700</pubDate>
<comments>http://hints.macworld.com/article.php?story=20120709152257934#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>I needed to restart a backup for one of my Macs, which had an 800 GB disk image on my Time Capsule. It turned out to be impossible to delete the disk image - in Finder, it would just not move to the Trash, even after waiting for several hours.&lt;br&gt;&lt;br&gt; I was looking for advice and most of the suggestions involved reformatting the Time Capsule, but I couldn't do this, as I had other Macs being backed up there.&lt;br&gt;&lt;br&gt; I looked for a way to do this from the command line. The Time Machine disk image - a sparsebundle, a special type of disk image that can increase in size as needed - is actually a package, which has &quot;bands&quot; inside, many smaller files that are named hexadecimally. In this case, there were thousands of them. So many, that even deleting them from the command line didn't work - commands like &lt;tt&gt;rm&lt;/tt&gt; &lt;tt&gt;find&lt;/tt&gt; limitations in the lengths of lists parsed by recursion or wildcards, so a basic command like &lt;tt&gt;rm -f&lt;/tt&gt; didn't work.&lt;br&gt;&lt;br&gt; I ended up writing a li ...</description>
</item>
<item>
<title>Save all of your Terminal activity to a file</title>
<link>http://hints.macworld.com/article.php?story=20120507163311559</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20120507163311559</guid>
<pubDate>Fri, 11 May 2012 07:30:00 -0700</pubDate>
<comments>http://hints.macworld.com/article.php?story=20120507163311559#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>I use Terminal everyday, and I find it a good idea to log everything I you. It makes it much easier to undo your mistakes when you know what those mistakes were. Here's how I do this:&lt;br&gt;&lt;br&gt; Open Terminal's preferences.&lt;br&gt;&lt;br&gt; Go to Settings, then Shell. You can choose here to run a command at startup. You could create a simple log of your session using the following:&lt;pre&gt;&lt;code&gt;/usr/bin/script ~/Desktop/Terminal.log&lt;/code&gt;&lt;/pre&gt;This will log everything you do and append it to the log file.&lt;br&gt;&lt;br&gt; I like to keep my history so instead I wrote this small script that archives previous sessions by renaming the file with a date/time string. I then set Terminal.app to run at startup the following command:&lt;pre&gt;&lt;code&gt;~/Desktop/logger.sh&lt;/code&gt;&lt;/pre&gt;Here's the script:&lt;pre&gt;&lt;code&gt;#!/bin/bash# logger.sh# Log everything you do in Terminal.#* Formatted date &amp;amp; time string.FORMATTED_DATE=`/bin/date &quot;+%Y-%m-%d%H%M%S&quot;`#* Archive the previous file/bin/cp -f ~/Desktop/Terminal ...&lt;/code&gt;&lt;/pre&gt;</description>
</item>
<item>
<title>Automatically restart network on lost connection </title>
<link>http://hints.macworld.com/article.php?story=2012041321461476</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=2012041321461476</guid>
<pubDate>Tue, 17 Apr 2012 07:30:00 -0700</pubDate>
<comments>http://hints.macworld.com/article.php?story=2012041321461476#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>Often times, for whatever reason, the Internet connection on my Mac will lock up. Only restarting the Airport or Ethernet interfaces seem to resolve the issue in a timely manner. (This is different from a router crash which requires a manual restart of the router - in my case an Airport Extreme.) I have developed some interconnected scripts that will automatically accomplish this task for me when attached to launchctl. This is important for me because I often have to access files over the internet and if the connection has locked up there is no way for me to access them without manual intervention.&lt;br&gt;&lt;br&gt; The first script gets the active network interface. This is called by the second script which determines whether to run a matched script for either the Ethernet or AirPort interfaces. These third and fourth scripts restart either the Ethernet or AirPort connection respectively. These last two scripts can also be configured to send you an e-mail if this happens by altering the ' ...</description>
</item>
<item>
<title>Automatically reclaim memory from leaky programs</title>
<link>http://hints.macworld.com/article.php?story=20120410153721860</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20120410153721860</guid>
<pubDate>Wed, 11 Apr 2012 07:30:00 -0700</pubDate>
<comments>http://hints.macworld.com/article.php?story=20120410153721860#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>Sometimes applications have a nasty habit of claiming a lot of memory and never releasing it back to the system. Over time, this can cause affect performance. Most of the time, this can simply be fixed by quitting and restarting the offending program, but I wanted to find a more elegant solution.&lt;br&gt;&lt;br&gt; After searching the Internet, I found few scripts that I could tweak to achieve what I wanted. Heres what I came up with. The first script is a python script I found at &lt;a href=&quot;http://stackexchange.com/&quot;&gt;StackExchange&lt;/a&gt; by user drfrogsplat that gets information about system memory. The second is a bash script I wrote that runs the purge command if you have over a certain amount of inactive memory, in my case 500MB (probably overkill). Note that I think you need developer tools installed to use the purge command. There's probably an easier way to do this with vm_stat directly but I'm not good enough at awk/grep/sed to it figure out.&lt;br&gt;&lt;br&gt; The bash script can be attached to  ...</description>
</item>
<item>
<title>Getting and setting printer options from the command line for use with lpadmin</title>
<link>http://hints.macworld.com/article.php?story=20120313110411984</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20120313110411984</guid>
<pubDate>Fri, 16 Mar 2012 07:30:00 -0700</pubDate>
<comments>http://hints.macworld.com/article.php?story=20120313110411984#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>lpadmin and lpoptions don't interact with OS X as you might think, or at least as they are documented. Here are some helpful notes and a script.&lt;br&gt;There are some good hints for adding printers via the command line with lpadmin: &lt;a href=&quot;http://hints.macworld.com/article.php?story=20061203221317612&quot;&gt;Managing multiple printers via the command line&lt;/a&gt;.&lt;br&gt;However, there is still confusion surrounding the setting of printer options from the command line, as a poster to Debian bugs pointed out back in 2006: &lt;a href=&quot;http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=381252&quot;&gt;lpoptions documentation doesn't&lt;/a&gt;. After doing some testing, here are the two main points to note:&lt;br&gt;&lt;br&gt;&lt;li&gt;If you use lpadmin and specify options with &quot;-o&quot;, the PPD is altered and OS X will recognize the options for the printer. &lt;li&gt;However, if you setup the printer using lpadmin without any options, and later use lptoptions to set the options, they are not written to the PPD and the GUI is unaware of the pr ...&lt;/li&gt;&lt;/li&gt;</description>
</item>
<item>
<title>10.7: Fix crash when running shell scripts from script menu</title>
<link>http://hints.macworld.com/article.php?story=20120127032453655</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20120127032453655</guid>
<pubDate>Wed, 14 Mar 2012 07:30:00 -0700</pubDate>
<comments>http://hints.macworld.com/article.php?story=20120127032453655#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>It seems that 10.7 no longer wants to run shell scripts from the script menu. This may also happen in 10.6, but I do not have an install to test it with.&lt;br&gt;&lt;br&gt; No matter what script I try, the SystemUIServer crashes. And somewhere in the crash report is this ominous message:&lt;br&gt;&lt;br&gt; USING_FORK_WITHOUT_EXEC_IS_NOT_SUPPORTED_BY_FILE_MANAGER&lt;br&gt;&lt;br&gt; This might have something to do with Apple tightening privileges for spawning processes, but it can be easily fixed by enclosing the shell script in AppleScript.&lt;br&gt;&lt;pre&gt;&lt;code&gt;do shell script &quot;sh ~/script.sh&quot;&lt;/code&gt;&lt;/pre&gt;[&lt;b&gt;kirkmc adds&lt;/b&gt;: I haven't tested this; I don't run shell scripts from the script menu, so I haven't seen crashes.] 
</description>
</item>
<item>
<title>Control+T in Terminal shows time snapshot</title>
<link>http://hints.macworld.com/article.php?story=20110810112318227</link>
<guid isPermaLink="true">http://hints.macworld.com/article.php?story=20110810112318227</guid>
<pubDate>Fri, 27 Jan 2012 07:30:00 -0800</pubDate>
<comments>http://hints.macworld.com/article.php?story=20110810112318227#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>Not sure if this was available before 10.7, but hitting Control+T while running a command in the Terminal will show what process is executing, the load, the PID of the process and its user and kernel time.&lt;br&gt;&lt;br&gt;I was running a script and accidentally hit Control+T instead of Command+T to create a new tab. I was surprised at what I got. Here is an example of what gets printed:&lt;div style=&quot;margin-left: 20px; margin-top:10px; margin-bottom:10px; padding: 5px; border:1px solid; width:520px; height:120px; overflow:scroll;white-space:nowrap;resize:both&quot;&gt;&lt;pre&gt;# buildOrder.pyload: 2.51  cmd: p4 15179 running 0.00u 0.00sload: 2.23  cmd: p4 17962 waiting 0.01u 0.00sload: 2.53  cmd: Python 15167 running 94.68u 66.33sload: 2.60  cmd: Python 15167 running 150.71u 101.82s&lt;/pre&gt;&lt;/div&gt;&lt;br&gt;[&lt;b&gt;crarko adds:&lt;/b&gt; I wasn't able to reproduce this, but it may be due to the briefness of the running command. Give it a try and post a comment about your results. Try it in Snow Leopard too if you  ...</description>
</item>
</channel>
</rss>
