<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mac Tricks And Tips &#187; Terminal</title>
	<atom:link href="http://www.mactricksandtips.com/category/terminal/feed" rel="self" type="application/rss+xml" />
	<link>http://www.mactricksandtips.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 09 Feb 2012 14:41:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Loop / Repeat Terminal Commands</title>
		<link>http://www.mactricksandtips.com/2012/02/loop-repeat-terminal-commands.html</link>
		<comments>http://www.mactricksandtips.com/2012/02/loop-repeat-terminal-commands.html#comments</comments>
		<pubDate>Mon, 06 Feb 2012 15:42:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=2142</guid>
		<description><![CDATA[I want to extend your Terminal knowledge today by introducing a simple loop command. This is useful if you want to repeat or loop a Terminal command indefinitely. This is a simple bash script that has a variety of uses. The script is a simple one line command that needs very little adjusting on your part.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2012/02/loop-repeat-terminal-commands.html">Loop / Repeat Terminal Commands</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/05/list-all-possible-terminal-commands.html' rel='bookmark' title='Permanent Link: List All Possible Terminal Commands'>List All Possible Terminal Commands</a></li>
<li><a href='http://www.mactricksandtips.com/2010/04/create-your-own-custom-terminal-commands.html' rel='bookmark' title='Permanent Link: Create Your Own Custom Terminal Commands'>Create Your Own Custom Terminal Commands</a></li>
<li><a href='http://www.mactricksandtips.com/2008/09/print-selected-information-from-terminal-commands.html' rel='bookmark' title='Permanent Link: Print Selected Info From Terminal Commands'>Print Selected Info From Terminal Commands</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>I want to extend your <a href="http://www.mactricksandtips.com/category/terminal">Terminal</a> knowledge today by introducing a simple loop command. This is useful if you want to repeat or loop a Terminal command indefinitely. This is a simple bash script that has a variety of uses. The script is a simple one line command that needs very little adjusting on your part.</p>
<p>The first step is to open up Terminal. Then copy and paste, or type, the following into the Terminal prompt.</p>
<p><code>bash -c 'while [ 0 ]; do date;done'</code></p>
<p>This will activate a bash script, and will repeat the listed command indefinitely, press Control + C to stop the loop. Replace the word <code>date</code>, with any command you want to run. This loop works when the program you want to run will have a defined exit. For example the command date will display the current date and time and then return you to the command prompt. A command such as <code>top</code>, will display the command but will immediately open the command again the second you exit <code>top</code>.</p>
<p>The loop listed will run the command as fast as possible, this is a little bit of overkill and the majority of commands are best used when a small amount of delay is present after each command is run. To achieve this in the loop we are going to add a sleep command, to pause the loop for a certain number of seconds. To add this into the loop type the following:</p>
<p><code>bash -c 'while [ 0 ]; do date;sleep 1;done'</code></p>
<p>This will cause the loop to pause for one second before it is repeated.</p>
<p>A simple loop that I will begin to implement in a couple of commands. If you want to learn more about bash programming I recommend <a href="http://www.amazon.com/gp/product/0596526784/ref=as_li_ss_tl?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0596526784">Bash Cookbook</a>, among the many useful books found on Amazon. If you have any questions, comments or extensions to this code, please leave a comment using the form below.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2012/02/loop-repeat-terminal-commands.html">Loop / Repeat Terminal Commands</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/05/list-all-possible-terminal-commands.html' rel='bookmark' title='Permanent Link: List All Possible Terminal Commands'>List All Possible Terminal Commands</a></li>
<li><a href='http://www.mactricksandtips.com/2010/04/create-your-own-custom-terminal-commands.html' rel='bookmark' title='Permanent Link: Create Your Own Custom Terminal Commands'>Create Your Own Custom Terminal Commands</a></li>
<li><a href='http://www.mactricksandtips.com/2008/09/print-selected-information-from-terminal-commands.html' rel='bookmark' title='Permanent Link: Print Selected Info From Terminal Commands'>Print Selected Info From Terminal Commands</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Stress Test Your Mac and CPU</title>
		<link>http://www.mactricksandtips.com/2012/02/stress-test-your-mac-and-cpu.html</link>
		<comments>http://www.mactricksandtips.com/2012/02/stress-test-your-mac-and-cpu.html#comments</comments>
		<pubDate>Sat, 04 Feb 2012 14:49:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1956</guid>
		<description><![CDATA[When you have a new or old Mac, every so often you will want to stress test your Mac to see if it has any problems or it can handle the heat. There are a variety of different ways in which you can do this, however one of the simplest ways is to use Terminal. This guide will show you how to set your CPU running at max speed, which you can tailor to the number of CPU's cores you have. Then its just a matter of watching the results in Activity Monitor, watch for stability issues and see the temperature of your Mac rise.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2012/02/stress-test-your-mac-and-cpu.html">Stress Test Your Mac and CPU</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/05/disabling-cpu-cores-on-a-mac.html' rel='bookmark' title='Permanent Link: Disabling CPU Cores On A Mac'>Disabling CPU Cores On A Mac</a></li>
<li><a href='http://www.mactricksandtips.com/2009/12/pause-an-app-using-terminal.html' rel='bookmark' title='Permanent Link: Pause An App Using Terminal'>Pause An App Using Terminal</a></li>
<li><a href='http://www.mactricksandtips.com/2008/05/cool-unix-terminal-comnmands.html' rel='bookmark' title='Permanent Link: Cool Unix Terminal Comnmands'>Cool Unix Terminal Comnmands</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>When you have a new or old Mac, every so often you will want to stress test your Mac to see if it has any problems or it can handle the heat. There are a variety of different ways in which you can do this, however one of the simplest ways is to use Terminal. This guide will show you how to set your CPU running at max speed, which you can tailor to the number of CPU&#8217;s cores you have. Then its just a matter of watching the results in Activity Monitor, watch for stability issues and see the temperature of your Mac rise.</p>
<p>The first step is to open Activity Monitor located in Applications &gt; Utilities folder. Set the entries in the list view to be ordered by CPU %, so you can see what is using your computer. Then, if required, install an app to monitor the temperature of your Mac. I recommend <a href="http://islayer.com/apps/">iStat</a>, either the dashboard or menu bar app, however <a href="http://www.bresink.com/osx/TemperatureMonitor.html">Temperature Monitor</a>, is also a good app if it is slightly more technical.</p>
<p>After you have opened your monitoring software we can now stress your CPU. Open Terminal. As a starter type the following into Terminal:</p>
<p><code>yes</code></p>
<p>You will notice, Terminal starts outputting the letter &#8216;y&#8217; and the CPU of your Mac increasing. The <a href="https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/yes.1.html">yes</a> command, will keep repeating this command indefinitely. To stop the process either press Control + C on your keyboard or close the Terminal window.</p>
<p>We can now use this command for each CPU (physical) core we have on your Mac. End the previous command, and type the following instead:</p>
<p><code>yes &gt; /dev/null</code></p>
<p>This will output the results of yes to a special location on your mac called <a href="http://en.wikipedia.org/wiki//dev/null">/dev/null</a> . This is done because opening up multiple instances of the yes command will not increase the load on your computer past 100%. However, when we pipe this command to /dev/null it will.</p>
<p>If you notice in Activity monitor your CPU load will increase to 100% of the yes command. This is fully loading one CPU core to its maximum. If you use something like iStat, you will notice the load is spread evenly between each cores, a feature of your operating system. To load the other cores, open up a new Terminal window, keeping the first one open, and repeat the command.</p>
<p>When you open two instances of the yes command being piped to /dev/null your load will increase to 200%, keep doing this for each core you have.</p>
<p><a href="http://www.mactricksandtips.com/wp-content/uploads/2012/02/mac-stress-test-cpu.png"><img class="aligncenter size-medium wp-image-1957" title="mac stress test cpu" src="http://www.mactricksandtips.com/wp-content/uploads/2012/02/mac-stress-test-cpu-300x180.png" alt="" width="300" height="180" /></a></p>
<p>One of the new features of the Intel cores is the ability to have <a href="http://en.wikipedia.org/wiki/Hyperthreading">hyper-threading</a>, as a result your Mac will report more cores than is physically present. This means if you have a quad core processor, your Mac will report eight cores. It allows your computer to run faster. However, in this stress test you will never be able to stress those extra four virtual cores. It doesn&#8217;t really matter, but means your CPU monitor will only fill half way, when in reality every core is running at full speed. It also means your the yes command can run at 100% (for each core) and other tasks can compute at the same time.</p>
<p>When you have finally finished stress testing your Mac, either close the Terminal window, of press Control + C. I let the command run for a couple of minutes and watched the CPU temperature slowly rise. If you think you have a problem with your CPU running at full speed, running this command and carrying out normal running of your Mac at the same time will help you eliminate any possible problems.</p>
<p>If you have any questions or comments, please leave one using the form below.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2012/02/stress-test-your-mac-and-cpu.html">Stress Test Your Mac and CPU</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/05/disabling-cpu-cores-on-a-mac.html' rel='bookmark' title='Permanent Link: Disabling CPU Cores On A Mac'>Disabling CPU Cores On A Mac</a></li>
<li><a href='http://www.mactricksandtips.com/2009/12/pause-an-app-using-terminal.html' rel='bookmark' title='Permanent Link: Pause An App Using Terminal'>Pause An App Using Terminal</a></li>
<li><a href='http://www.mactricksandtips.com/2008/05/cool-unix-terminal-comnmands.html' rel='bookmark' title='Permanent Link: Cool Unix Terminal Comnmands'>Cool Unix Terminal Comnmands</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>View Terminal &#8216;man&#8217; Pages In Preview / PDF</title>
		<link>http://www.mactricksandtips.com/2012/01/view-terminal-man-pages-in-preview-pdf.html</link>
		<comments>http://www.mactricksandtips.com/2012/01/view-terminal-man-pages-in-preview-pdf.html#comments</comments>
		<pubDate>Mon, 30 Jan 2012 15:52:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1938</guid>
		<description><![CDATA[If you use Terminal regularly you may find yourself reading the 'man', pages frequently. These stand for manual and are the help guides for using the different commands. In Terminal if you type man command, where commands is replaced by the command you are using you can view the help guide. Quickly scrolling and viewing the data within the command can be a bit of a pain. For a very long command with many pages of help, it can be a little slow to view all of the information. To help us in this problem we can use a Terminal command to convert the man page to view in Preview. This is a lot more user friendly and allows you to use the resulting file like any pdf.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2012/01/view-terminal-man-pages-in-preview-pdf.html">View Terminal &#8216;man&#8217; Pages In Preview / PDF</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/07/view-terminal-help-pages-online.html' rel='bookmark' title='Permanent Link: View Terminal Help Pages Online'>View Terminal Help Pages Online</a></li>
<li><a href='http://www.mactricksandtips.com/2008/06/terminal-help-pages.html' rel='bookmark' title='Permanent Link: Terminal Help Pages'>Terminal Help Pages</a></li>
<li><a href='http://www.mactricksandtips.com/2008/10/joining-pdf-files-together-in-preview.html' rel='bookmark' title='Permanent Link: Joining PDF Files Together In Preview'>Joining PDF Files Together In Preview</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>If you use <a href="http://www.mactricksandtips.com/category/terminal">Terminal</a> regularly you may find yourself reading the &#8216;man&#8217;, pages frequently. These stand for manual and are the help guides for using the different commands. In Terminal if you type <code>man command</code>, where commands is replaced by the command you are using you can view the help guide. Quickly scrolling and viewing the data within the command can be a bit of a pain. For a very long command with many pages of help, it can be a little slow to view all of the information. To help us in this problem we can use a Terminal command to convert the man page to view in Preview. This is a lot more user friendly and allows you to use the resulting file like any pdf.</p>
<p>To view your man pages to one viewable in preview open up Terminal and type or paste in the following and hit enter. Replace xyz with the command you want to view the man page.<br />
<code><br />
man -t xyz | open -f -a /Applications/Preview.app</code></p>
<p>For example if we want to view the ssh man page in Preview we type the following:<br />
<code><br />
man -t ssh | open -f -a /Applications/Preview.app</code></p>
<p>Once Preview has done a bit of post processing you will be presented a 13-page pdf with the contents of the ssh man page. Due to the formatting involved with the man page, the resulting output is easy to read and well laid out. Simply save the file out using the Save As menu option, give it a useful name and you are all done.</p>
<p><a href="http://www.mactricksandtips.com/wp-content/uploads/2012/01/Terminal-man-page-in-preview.png"><img class="aligncenter size-medium wp-image-1939" title="Terminal man page in preview" src="http://www.mactricksandtips.com/wp-content/uploads/2012/01/Terminal-man-page-in-preview-297x300.png" alt="" width="297" height="300" /></a></p>
<p>Try it yourself, I have been in the process of converting a lot my regularly used man pages in PDF&#8217;s. If you find you use this command regularly you can program it as a function Terminal can use. In Terminal type the following, assuming you have a freshly opened Terminal window in the default user path.</p>
<p><code>open .bash_profile</code></p>
<p>In the file that opens in TextEdit enter the following:</p>
<p><code>manpre () {<br />
man -t $@ | open -f -a /Applications/Preview.app<br />
}</code></p>
<p>You can change <code>manpre</code> to anything you want, something memorable. Save the file, close TextEdit and Quit and re-launch Terminal. Now every time you type the following into Terminal it will load the command you have just entered and convert the man page into a readable one in Preview.</p>
<p><code>manpre ssh</code></p>
<p>If you want to remove the command from Terminal, open up .bash_profile and delete the lines in the file.</p>
<p>Simple and clean. I prefer reading the PDF, Preview, versions of man pages over ones in Terminal as it is faster and I get the search function of Preview, very useful if I have a large man page and want to find something specific. If you have any questions or comments about this command, please leave one using the form below.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2012/01/view-terminal-man-pages-in-preview-pdf.html">View Terminal &#8216;man&#8217; Pages In Preview / PDF</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/07/view-terminal-help-pages-online.html' rel='bookmark' title='Permanent Link: View Terminal Help Pages Online'>View Terminal Help Pages Online</a></li>
<li><a href='http://www.mactricksandtips.com/2008/06/terminal-help-pages.html' rel='bookmark' title='Permanent Link: Terminal Help Pages'>Terminal Help Pages</a></li>
<li><a href='http://www.mactricksandtips.com/2008/10/joining-pdf-files-together-in-preview.html' rel='bookmark' title='Permanent Link: Joining PDF Files Together In Preview'>Joining PDF Files Together In Preview</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Generate Random Numbers In Terminal/Bash</title>
		<link>http://www.mactricksandtips.com/2012/01/generate-random-numbers-in-terminalbash.html</link>
		<comments>http://www.mactricksandtips.com/2012/01/generate-random-numbers-in-terminalbash.html#comments</comments>
		<pubDate>Fri, 27 Jan 2012 19:07:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1933</guid>
		<description><![CDATA[I have a previously discussed about generating random numbers in applescript, today I am going to discuss two methods which you can use to generate random numbers in Terminal. This is useful for bash, terminal or any other scripts which use the language.  The two methods allow you to have a certain element of control on the size and the randomness and type of number produced. There are certain levels of randomness with random numbers produced by computers. One of the options shown will use an aspect of your Mac which is very random.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2012/01/generate-random-numbers-in-terminalbash.html">Generate Random Numbers In Terminal/Bash</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/10/customizing-the-mac-terminal-bash-prompt.html' rel='bookmark' title='Permanent Link: Customizing The Mac Terminal Bash Prompt'>Customizing The Mac Terminal Bash Prompt</a></li>
<li><a href='http://www.mactricksandtips.com/2008/03/apple-script-random-number-generator.html' rel='bookmark' title='Permanent Link: Apple Script Random Number Generator'>Apple Script Random Number Generator</a></li>
<li><a href='http://www.mactricksandtips.com/2008/07/generate-passwords-from-the-menu-bar.html' rel='bookmark' title='Permanent Link: Generate Passwords From The Menu Bar'>Generate Passwords From The Menu Bar</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>I have a previously discussed about <a href="http://www.mactricksandtips.com/2008/03/apple-script-random-number-generator.html">generating random numbers in applescript</a>, today I am going to discuss two methods which you can use to generate random numbers in Terminal. This is useful for bash, terminal or any other scripts which use the language.  The two methods allow you to have a certain element of control on the size and the randomness and type of number produced. There are certain levels of <a href="http://www.random.org/randomness/">randomness</a> with random numbers produced by computers. One of the options shown will use an aspect of your Mac which is very random. If you don&#8217;t want the book versions of a <a href="http://www.amazon.com/gp/product/0833030477/ref=as_li_ss_tl?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0833030477">Million Random Digits</a>, using a computer is probably better.</p>
<h3>Option One</h3>
<p>This first options is rather simple, and great if you want a simple number for your script. Simply type the following into Terminal or your bash script, note that it has to be written in capitals:</p>
<p><code>echo $RANDOM</code></p>
<p>This will output a number up to 32,767, for those interested it is a <a href="http://en.wikipedia.org/wiki/Integer_%28computer_science%29">signed halfword</a> noted for being 16 bits in length. If you want to limit the random number up to a certain length simply type the following:</p>
<p><code>echo $[RANDOM%X+1]</code></p>
<p>Where X is your largest number you want, although it has to be less than 32,767. If you want a longer random number you can simply repeat the $RANDOM section of the command, such as the following:</p>
<p><code>echo $RANDOM$RANDOM</code></p>
<p>Using a combination of the previous two commands you can tailor the size of the number to anything you want. Although this method is simple and for most cases satisfactory I am unsure on the complete randomness of the number. The second command will have more randomness, although the first option is based on this command.</p>
<h3>Option Two</h3>
<p>This second command will use something called <a href="http://en.wikipedia.org/wiki//dev/urandom">/dev/urandom</a>, which is based on something called /dev/random. It takes noise in your system, such as mouse movements, network cards, hard drive access to name a few and output the random data to /dev/random and dev/urandom. We can then take the random 0&#8242;s and 1&#8242;s produced and convert them into a numerical number which we can use. This commands has slightly more control over the size and types of numbers which we produce.</p>
<p>The command to generate this random number is as follows:</p>
<p><code>od -vAn -N4 -tu &lt; /dev/urandom</code></p>
<p>This will generate a large number which you can use as your random number. There are two options which I would like to draw your attention to, although you can read about the <code>od</code> command, which is used to output the number on its <a href="http://compute.cnr.berkeley.edu/cgi-bin/man-cgi?od">man page</a>, the two options which are best changed is the number following the capital N, and the letter u between the t and 4 within the command options.</p>
<p>The -N options is used to control the size of the number in bytes, the number four will produce a ten digit number. If you increase the size of this number, eg to 5, it will split the outputted number into a 4 byte, 10 digit number and then into a one byte number. If you remove this option completely from the command, it will keep producing numbers.</p>
<p>The next option is to change the -tu4 to something different. You can change the letter u to either, d, o, or x. The letter d will produce a signed decimal to produce a value from − 2,147,483,648 to 2,147,483,647. The letter o will produce an octal value, where as u will produced an unsigned value of 0 to 4,294,967,295. Finally x will produce a hexadecimal value. For example:<br />
<code><br />
od -vAn -N4 -tx &lt; /dev/urandom</code></p>
<p>Produces the output, 05f70be9. Neat.</p>
<h3>Conclusion</h3>
<p>To conclude. The first option, is quick and easy. It allows you to generate a number and input them into a script will little thinking. The second option is more complex but allows you to have more control over the final output. Certainly more efficent than buying a <a href="http://www.amazon.com/gp/product/0833030477/ref=as_li_ss_tl?ie=UTF8&#038;tag=mact06-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0833030477">book with random numbers</a>.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2012/01/generate-random-numbers-in-terminalbash.html">Generate Random Numbers In Terminal/Bash</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/10/customizing-the-mac-terminal-bash-prompt.html' rel='bookmark' title='Permanent Link: Customizing The Mac Terminal Bash Prompt'>Customizing The Mac Terminal Bash Prompt</a></li>
<li><a href='http://www.mactricksandtips.com/2008/03/apple-script-random-number-generator.html' rel='bookmark' title='Permanent Link: Apple Script Random Number Generator'>Apple Script Random Number Generator</a></li>
<li><a href='http://www.mactricksandtips.com/2008/07/generate-passwords-from-the-menu-bar.html' rel='bookmark' title='Permanent Link: Generate Passwords From The Menu Bar'>Generate Passwords From The Menu Bar</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clear Terminal History</title>
		<link>http://www.mactricksandtips.com/2012/01/clear-terminal-history.html</link>
		<comments>http://www.mactricksandtips.com/2012/01/clear-terminal-history.html#comments</comments>
		<pubDate>Wed, 25 Jan 2012 16:56:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1929</guid>
		<description><![CDATA[This is a rather simple tip that will allow you to clear Terminal history either selectively or every entry within the terminals history file. When you type in Terminal history it will show you every single entry you have made. Previously I have mentioned how you can change the history size to suit, however if it is becoming rather large, or you want to remove entries that you do not want other people to access, such as a super secret location you don't want other people to find out about, it is worth removing entries.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2012/01/clear-terminal-history.html">Clear Terminal History</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/04/opening-terminal-files-in-a-different-app.html' rel='bookmark' title='Permanent Link: Opening Terminal Files In A Different App'>Opening Terminal Files In A Different App</a></li>
<li><a href='http://www.mactricksandtips.com/2010/04/create-your-own-custom-terminal-commands.html' rel='bookmark' title='Permanent Link: Create Your Own Custom Terminal Commands'>Create Your Own Custom Terminal Commands</a></li>
<li><a href='http://www.mactricksandtips.com/2008/10/customizing-the-mac-terminal-bash-prompt.html' rel='bookmark' title='Permanent Link: Customizing The Mac Terminal Bash Prompt'>Customizing The Mac Terminal Bash Prompt</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>This is a rather simple tip that will allow you to clear Terminal history either selectively or every entry within the terminals history file. When you type in Terminal <code>history</code> it will show you every single entry you have made. <a href="http://www.mactricksandtips.com/2008/10/customizing-the-mac-terminal-bash-prompt.html">Previously</a> I have mentioned how you can change the history size to suit, however if it is becoming rather large, or you want to remove entries that you do not want other people to access, such as a super secret location you don&#8217;t want other people to find out about, it is worth removing entries.</p>
<p>To clear every entry in Terminals history type the following into the command prompt.</p>
<p><code>history -c</code></p>
<p>Within a blink of an eye, the history will be cleared, not that you cannot reverse this command so ensure you really want to clear you history. Now when you press the up button on your keyboard, no entries will be displayed.</p>
<p>If clearing the history is a bit to extreme, or there is just one entry you want to remove, such as an incorrect command from your list you do not want to repeat it is better to selectively remove the entry. This is done by modifying .bash_history. It is a hidden file located in your User directory that is accessed every time Terminal writes it&#8217;s history to disk. In a new Terminal prompt (to ensure you are at your User folder by default), type the following:</p>
<p><code>ls -a</code></p>
<p>This will show you all of the hidden files and folder. If you look through the list you should notice a file called .bash_history. To modify this file type the following:</p>
<p><code>nano .bash_history</code></p>
<p>You can now use the nano text editor to modify each line. If you don&#8217;t know how to use the nano text editor, the <a href="http://www.nano-editor.org/">nano editor homepage</a> is a good place to look, or you would rather use TextEdit, instead type the following into Terminal:</p>
<p><code>open .bash_history</code></p>
<p>This will open up TextEdit, now you can modify the file a lot quicker and easier. Delete the lines as you see fit. When you have finished simply save the file in TextEdit and restart the Terminal app to ensure the change has taken effect.</p>
<p>It is only a simple change but it can be useful if there is an incorrect command that you want to remove, I find I use the history to quickly select commands and it is always annoying when you have to scroll past incorrect commands. If you want to learn more about Mac Terminal commands, either look through the <a href="http://www.mactricksandtips.com/category/terminal">Terminal commands</a> section on this site or read a recommended <a href="http://www.amazon.com/gp/product/0470478365/ref=as_li_ss_tl?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0470478365">Terminal Book</a> from Amazon.</p>
<p>P.S Sorry for the long time between the last post, this last year was really busy and finding time to work on this site was a bit problematic.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2012/01/clear-terminal-history.html">Clear Terminal History</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/04/opening-terminal-files-in-a-different-app.html' rel='bookmark' title='Permanent Link: Opening Terminal Files In A Different App'>Opening Terminal Files In A Different App</a></li>
<li><a href='http://www.mactricksandtips.com/2010/04/create-your-own-custom-terminal-commands.html' rel='bookmark' title='Permanent Link: Create Your Own Custom Terminal Commands'>Create Your Own Custom Terminal Commands</a></li>
<li><a href='http://www.mactricksandtips.com/2008/10/customizing-the-mac-terminal-bash-prompt.html' rel='bookmark' title='Permanent Link: Customizing The Mac Terminal Bash Prompt'>Customizing The Mac Terminal Bash Prompt</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Join avi Or Other Movie Files Together</title>
		<link>http://www.mactricksandtips.com/2011/01/join-avi-or-other-movie-files-together.html</link>
		<comments>http://www.mactricksandtips.com/2011/01/join-avi-or-other-movie-files-together.html#comments</comments>
		<pubDate>Wed, 05 Jan 2011 14:56:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1886</guid>
		<description><![CDATA[In this modern digital world we generate a lot of digital media, one of the most prevalent is movies. After a while I have a lot of indiviual movie files that could be better used as one long movie. This post aims to show you how to combine these movie files into one long movie. This isn't going to use an app like iMovie where you have to create a movie or apply any video editing. This post is going to show you how to stick lots of movies together in a simple and easy to use way. There is going to be two methods shown, one using Terminal and one with Quicktime, where you can pick the best option for yourself.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2011/01/join-avi-or-other-movie-files-together.html">Join avi Or Other Movie Files Together</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2009/07/converting-movie-files-quickly-and-easily.html' rel='bookmark' title='Permanent Link: Converting Movie Files Quickly And Easily'>Converting Movie Files Quickly And Easily</a></li>
<li><a href='http://www.mactricksandtips.com/2008/07/set-a-movie-as-a-wallpaper.html' rel='bookmark' title='Permanent Link: Set A Movie As A Wallpaper'>Set A Movie As A Wallpaper</a></li>
<li><a href='http://www.mactricksandtips.com/2008/07/make-quick-multi-file-files-w-terminal.html' rel='bookmark' title='Permanent Link: Make Quick Multi File Files w/ Terminal'>Make Quick Multi File Files w/ Terminal</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hello</p>
<p>In this modern digital world we generate a lot of digital media, one of the most prevalent is movies. After a while I have a lot of indiviual movie files that could be better used as one long movie. This post aims to show you how to combine these movie files into one long movie. This isn&#8217;t going to use an app like iMovie where you have to create a movie or apply any video editing. This post is going to show you how to stick lots of movies together in a simple and easy to use way. There is going to be two methods shown, one using Terminal and one with Quicktime, where you can pick the best option for yourself.</p>
<h3>Using Terminal</h3>
<p>The first method I am going to show you is to use a couple of Terminal commands. This is slightly more complicated however in the long run it will process your movie files quicker. This options takes the individual movie files, sticks them together and then sorts out the header section of the movie file so it will play correctly. The method using Quicktime will involve it re-encoding the files and can take a long time.</p>
<p>To begin with this method change directory to where you movie files are located. First open up Terminal located in Applications &gt; Utilites. Do this using the change directory command. You can either type the path out by hand or drop the folder into the Terminal window and press enter.</p>
<p><code>cd /path/to/seperate/video/files</code></p>
<p>We now need to stick the files together into one file. This process will take the second file, put the bytes on the end of the first file and repeat until it has gone through all of the files in the list. I like to think of it as putting a book together. You take your second book, spread glue on the cover and stick to the back of the first book. To do this in Terminal, we put out glue pot down, and use the cat, from the word&#8221;con<strong>cat</strong>enate&#8221; cocommand.<br />
<code><br />
cat video1.avi video2.avi videon.avi &gt; output.avi</code></p>
<p>The cat command will take videos 1 and 2 and stick them together, it will place them in the order in the list so don&#8217;t get them mixed up. You can add as many as you want to the list, it doesn&#8217;t have to be two items long however I would keep in mind that really long list of video files to stick together may cause some problems, so if you have hundreds of files it may be best to do this in bulk. When this has finished you will noticed to things. First the file size of output.avi is the same as the sum of video1 and video2. Second, when you play the avi file it will only play the length to the length of the first video. This is beacause the header section of the first avi only knows its original length. Going back to our book analogy the contents page of the first book, only knows the contents of the first book and not the second. What we now need to do is rebuild the header file so it knows about the second video (or second book contents). This will make sure when it plays it plays all of the video and not just the first part.</p>
<p>To do this we are going to use a program called <a href="http://en.wikipedia.org/wiki/MEncoder">mencoder</a>. Its from a site called <a href="http://www.mplayerhq.hu/">mplayerhq</a>, however we only need the binary for Terminal. To do this head over to <a href="http://stefpause.com/apple/mac/mplayer-os-x-10rc1-and-mencoder-binaries/">stefpause</a> and download the mencoder bianry located at the bottom of the page. When you have downloaded the binary move it using the following command.<br />
<code><br />
sudo mv /path/to/mencoder /usr/local/bin</code></p>
<p>Terminal will ask for your admin password. This is done so you only have to write &#8220;mencoder&#8221; in Terminal and not the path to the mencoder file. More information on install this app can be found <a href="http://snippets.aktagon.com/snippets/132-How-to-install-ffmpeg-mencoder-and-flvtool2-on-Mac-OSX-Leopard-convert-an-AVI-to-FLV-and-view-the-FLV-video-with-FlowPlayer">here</a>.</p>
<p>Now that we have mencoder installed we can use it rebuild the header of our avi file. To do this write or copy and paste the following into Terminal. The command assumes you are in the same location as the file output.avi created earlier.</p>
<p><code>mencoder -forceidx -oac copy -ovc copy output.avi -o output_final.avi;</code></p>
<p>In a nutshell this commands rebuilds the header file. One unqiue point about this commands is that it only copies the frames and audio across, it doesn&#8217;t re-encode them. This saves a lot of time in building the final file. Most of the time you don&#8217;t need to re-encode anything. If you want more of an understanding of mencoder you can read the <a href="http://www1.mplayerhq.hu/MPlayer/DOCS/HTML/en/mencoder.html">basic help</a>.</p>
<p>When the command has finished, which shouldn&#8217;t take to long you should now have a working avi file which is the correct lenght and contains all of the previous videos.</p>
<p>To summarise the commands are:</p>
<p><code>cat video1.avi video2.avi videon.avi &gt; output.avi<br />
mencoder -forceidx -oac copy -ovc copy output.avi -o output_final.avi;<br />
rm output.avi</code></p>
<p>The last line removes the incorrect output file from the cat command. There you have it a video made from the sum of the smaller parts. Once you understand what is happening this command is very fast and very useful.</p>
<p>If you want to learn more about cat and other unix commands I recommend <a href="http://www.amazon.com/gp/product/0470478365?ie=UTF8&#038;tag=mact06-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0470478365">Mac OS X  Toolbox</a>, if you want to learn more about mencoder amazon has thrown <a href="http://www.amazon.com/gp/product/6131980470?ie=UTF8&#038;tag=mact06-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=6131980470">this book</a> up, although I am dubious to it content.</p>
<h3>Using Quicktime</h3>
<p>If you are not very confident in using Terminal and want more more application based method, Quicktime Player 7, located in Applications &gt; Utilites in Mac OS X 10.6,  has an option to do this sort of thing. The only downside is that you don&#8217;t have much control on the final video specs. I have found that it does a bit of re-encoding as well as converting the file from avi to mov. However if all you want to do is stick some movies together this method it very simple.</p>
<p>To begin with open up Quicktime located in the Utilites folder. Then open up your first movie. Move the scrubber to the far right as shown in the image below.</p>
<p><a href="http://www.mactricksandtips.com/wp-content/uploads/2011/01/quicktime-scrubber.png"><img class="aligncenter size-medium wp-image-1887" title="quicktime scrubber" src="http://www.mactricksandtips.com/wp-content/uploads/2011/01/quicktime-scrubber-300x38.png" alt="" width="300" height="38" /></a></p>
<p>Then drag and drop your second movie onto Quicktime, move the scrubber the far right and repeat.</p>
<p>When you have finished compling your movie go to File &gt; Save As and select self-contained movie. The app will compile your movie and spit it out.</p>
<p>If you want to learn more about Quicktime something like <a href="http://www.amazon.com/gp/product/0240804961?ie=UTF8&#038;tag=mact06-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0240804961">QuickTime for Filmmakers</a> is very well rated. </p>
<h3>Conclusion</h3>
<p>In total these are two of many methods where you can combine movie files together. I prefer the Terminal method since it is quicker, however the Quicktime method may be more useful and easier to remember if you don&#8217;t use Terminal that frequently.</p>
<p>If you have any questions or comments about this trick please leave them below.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2011/01/join-avi-or-other-movie-files-together.html">Join avi Or Other Movie Files Together</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2009/07/converting-movie-files-quickly-and-easily.html' rel='bookmark' title='Permanent Link: Converting Movie Files Quickly And Easily'>Converting Movie Files Quickly And Easily</a></li>
<li><a href='http://www.mactricksandtips.com/2008/07/set-a-movie-as-a-wallpaper.html' rel='bookmark' title='Permanent Link: Set A Movie As A Wallpaper'>Set A Movie As A Wallpaper</a></li>
<li><a href='http://www.mactricksandtips.com/2008/07/make-quick-multi-file-files-w-terminal.html' rel='bookmark' title='Permanent Link: Make Quick Multi File Files w/ Terminal'>Make Quick Multi File Files w/ Terminal</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Stop A Stuck Time Machine Backup</title>
		<link>http://www.mactricksandtips.com/2010/12/stop-a-stuck-time-machine-backup.html</link>
		<comments>http://www.mactricksandtips.com/2010/12/stop-a-stuck-time-machine-backup.html#comments</comments>
		<pubDate>Wed, 22 Dec 2010 18:19:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1873</guid>
		<description><![CDATA[I love Time Machine. Its a simple way to keep all your files backed up and my Time Capsule is slowly filling up with data. I have, however, come across a problem here the back up process itself does get stuck. This recently happened to a friend and in short of restarting or pulling out the cable I wanted to find a more graceful method. I've found two ways to stop a stuck time machine backup.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/12/stop-a-stuck-time-machine-backup.html">Stop A Stuck Time Machine Backup</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/02/increasing-time-machine-backup-interval.html' rel='bookmark' title='Permanent Link: Increasing Time Machine Backup Interval'>Increasing Time Machine Backup Interval</a></li>
<li><a href='http://www.mactricksandtips.com/2009/09/backup-solutions-for-the-mac.html' rel='bookmark' title='Permanent Link: Backup Solutions For The Mac'>Backup Solutions For The Mac</a></li>
<li><a href='http://www.mactricksandtips.com/2009/07/using-time-machine-13-noob2pro.html' rel='bookmark' title='Permanent Link: Using Time Machine &#8211; #13 Noob2Pro'>Using Time Machine &#8211; #13 Noob2Pro</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>I love <a href="http://www.apple.com/macosx/what-is-macosx/time-machine.html">Time Machine</a>. Its a simple way to keep all your files backed up and my <a href="http://www.amazon.com/gp/product/B002TLTGJ4?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B002TLTGJ4">Time Capsule</a> is slowly filling up with data. I have, however, come across a problem here the back up process itself does get stuck. This recently happened to a friend and in short of restarting or pulling out the cable I wanted to find a more graceful method. I&#8217;ve found two ways to stop a stuck time machine backup.</p>
<p>The first command which you write in Terminal (Applications &gt; Utilities) is</p>
<p><code>sudo service com.apple.metadata.mds stop<br />
</code><br />
and if you want to restart the service (which you do),<br />
<code><br />
sudo service com.apple.metadata.mds start</code></p>
<p>This is known to work in 10.5. If however these two commands don&#8217;t work, which may be prevalent in the latest operating systems you can try.</p>
<p><code>sudo launchctl stop /System/Library/LaunchDaemons/com.apple.metadata.mds.plist<br />
sudo launchctl start /System/Library/LaunchDaemons/com.apple.metadata.mds.plist</code></p>
<p>Again written in Terminal. The latter is probably best if you are using Mac OS X 10.6</p>
<p>Hopefully this will solve any stuck time machine backups. I haven&#8217;t yet experienced such a problem, I am however assured that these two methods do work.</p>
<p>If you want more general tips and tricks I recommend <a href="http://www.amazon.com/gp/product/059652952X?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=059652952X">The Missing Manual</a> or <a href="http://www.amazon.com/gp/product/0470878681?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0470878681">Macs For Dummies</a>. In the mean time I am going to watch <a href="http://www.amazon.com/gp/product/B00005JKLZ?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B00005JKLZ">The Time Machine</a> since I have time travel related problems whizzing round my head.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/12/stop-a-stuck-time-machine-backup.html">Stop A Stuck Time Machine Backup</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/02/increasing-time-machine-backup-interval.html' rel='bookmark' title='Permanent Link: Increasing Time Machine Backup Interval'>Increasing Time Machine Backup Interval</a></li>
<li><a href='http://www.mactricksandtips.com/2009/09/backup-solutions-for-the-mac.html' rel='bookmark' title='Permanent Link: Backup Solutions For The Mac'>Backup Solutions For The Mac</a></li>
<li><a href='http://www.mactricksandtips.com/2009/07/using-time-machine-13-noob2pro.html' rel='bookmark' title='Permanent Link: Using Time Machine &#8211; #13 Noob2Pro'>Using Time Machine &#8211; #13 Noob2Pro</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Install Apple Updates From Terminal</title>
		<link>http://www.mactricksandtips.com/2010/12/install-apple-updates-from-terminal.html</link>
		<comments>http://www.mactricksandtips.com/2010/12/install-apple-updates-from-terminal.html#comments</comments>
		<pubDate>Mon, 20 Dec 2010 20:43:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1865</guid>
		<description><![CDATA[Sorry its been a long time since the last post, so I am going to start with an interesting one. I quite enjoying digging out and finding new command line updates to run and use. Today's command line post will allow you to download and install software updates from Terminal or the command line. Its great for those scripts you may be building and want to add that extra functionality to them.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/12/install-apple-updates-from-terminal.html">Install Apple Updates From Terminal</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/08/five-quick-terminal-tips.html' rel='bookmark' title='Permanent Link: Five Quick Terminal Tips'>Five Quick Terminal Tips</a></li>
<li><a href='http://www.mactricksandtips.com/2008/07/installing-wget-on-your-mac-for-terminal.html' rel='bookmark' title='Permanent Link: Installing wget On Your Mac For Terminal'>Installing wget On Your Mac For Terminal</a></li>
<li><a href='http://www.mactricksandtips.com/2008/09/delete-problem-files-with-terminal.html' rel='bookmark' title='Permanent Link: Delete Problem Files With Terminal'>Delete Problem Files With Terminal</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hello Again,</p>
<p>Sorry its been a long time since the last post, so I am going to start with an interesting one. I quite enjoying digging out and finding new command line updates to run and use. Today&#8217;s command line post will allow you to download and install software updates from Terminal or the command line. Its great for those scripts you may be building and want to add that extra functionality to them.</p>
<p>To run this command line, first open up Terminal from Applications &gt; Utilities. Within Terminal type the following:</p>
<p><code>sudo softwareupdate -i -v -a</code></p>
<p>This script will run and do the following: First it will invoke the software update tool, it will then install any available updates using the -i modifier, it will also install all of them using the -a modifier. Finally the -v modifier will tell you what is happening. In short, look, download, install.</p>
<p>If you want to use this tool but you don&#8217;t want to install anything. You can let the tool list any downloads available to you. To do this type the following:<br />
<code><br />
sudo softwareupdate -l</code></p>
<p>The, -l, modifier will list any updates. It may take a while for anything to appear, its best to let it run. You will get something similar to the image below if any updates are available.</p>
<p><a href="http://www.mactricksandtips.com/wp-content/uploads/2010/12/terminal-software-update.png"><img class="aligncenter size-medium wp-image-1866" title="terminal software update" src="http://www.mactricksandtips.com/wp-content/uploads/2010/12/terminal-software-update-300x107.png" alt="" width="300" height="107" /></a></p>
<p>A simple and useful command, that is quite interesting. If you want more information on this tool, type the following into Terminal.</p>
<p><code>man softwareupdate</code></p>
<p>If you want more information on Terminal or the Mac OS in general I recommend you check out <a href="http://www.amazon.com/gp/product/0596153287?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0596153287">Mac OS X: The Missing Manual</a> or <a href="http://www.amazon.com/gp/product/0470478365?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0470478365">Mac OS X Unix Toolbox</a>.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/12/install-apple-updates-from-terminal.html">Install Apple Updates From Terminal</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/08/five-quick-terminal-tips.html' rel='bookmark' title='Permanent Link: Five Quick Terminal Tips'>Five Quick Terminal Tips</a></li>
<li><a href='http://www.mactricksandtips.com/2008/07/installing-wget-on-your-mac-for-terminal.html' rel='bookmark' title='Permanent Link: Installing wget On Your Mac For Terminal'>Installing wget On Your Mac For Terminal</a></li>
<li><a href='http://www.mactricksandtips.com/2008/09/delete-problem-files-with-terminal.html' rel='bookmark' title='Permanent Link: Delete Problem Files With Terminal'>Delete Problem Files With Terminal</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Open Your Current Terminal Directory In Finder</title>
		<link>http://www.mactricksandtips.com/2010/08/open-your-current-terminal-directory-in-finder.html</link>
		<comments>http://www.mactricksandtips.com/2010/08/open-your-current-terminal-directory-in-finder.html#comments</comments>
		<pubDate>Tue, 17 Aug 2010 20:12:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1833</guid>
		<description><![CDATA[I found a rather cool little tip that I thought I would post. Its in regards to opening the current folder you are browsing in while using Terminal. Many times I have wondered if there was a way to view my current folder, this is usually very useful if you are very deep within a directory and need to have a more visual look at it with Finder. I've also found that its useful when viewing the output of any bash scripts.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/08/open-your-current-terminal-directory-in-finder.html">Open Your Current Terminal Directory In Finder</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/08/close-all-but-the-current-finder-window.html' rel='bookmark' title='Permanent Link: Close All But The Current Finder Window'>Close All But The Current Finder Window</a></li>
<li><a href='http://www.mactricksandtips.com/2008/11/open-terminal-output-directly-in-textedit.html' rel='bookmark' title='Permanent Link: Open Terminal Output Directly In TextEdit'>Open Terminal Output Directly In TextEdit</a></li>
<li><a href='http://www.mactricksandtips.com/2008/03/moving-around-in-finder.html' rel='bookmark' title='Permanent Link: Moving Around In Finder'>Moving Around In Finder</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>I found a rather cool little tip that I thought I would post. Its in regards to opening the current folder you are browsing in while using Terminal. Many times I have wondered if there was a way to view my current folder, this is usually very useful if you are very deep within a directory and need to have a more visual look at it with Finder. I&#8217;ve also found that its useful when viewing the output of any bash scripts.</p>
<p>To open the folder you are viewing in Terminal type the following:</p>
<p><code>open .</code></p>
<p>The word &#8220;open&#8221; is followed with a dot, without it it doesn&#8217;t work.</p>
<p>You can combine the open command with the change directory command. This is useful if you want to do something in Terminal and view the Finder window belonging to it.</p>
<p><code>cd /path/to/folder; open .</code></p>
<p>You can write it as one line and is a quick way to move around Terminal and Finder in one.</p>
<p>Within a couple of days i&#8217;ll have another post on using the open command. It is very useful.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/08/open-your-current-terminal-directory-in-finder.html">Open Your Current Terminal Directory In Finder</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/08/close-all-but-the-current-finder-window.html' rel='bookmark' title='Permanent Link: Close All But The Current Finder Window'>Close All But The Current Finder Window</a></li>
<li><a href='http://www.mactricksandtips.com/2008/11/open-terminal-output-directly-in-textedit.html' rel='bookmark' title='Permanent Link: Open Terminal Output Directly In TextEdit'>Open Terminal Output Directly In TextEdit</a></li>
<li><a href='http://www.mactricksandtips.com/2008/03/moving-around-in-finder.html' rel='bookmark' title='Permanent Link: Moving Around In Finder'>Moving Around In Finder</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Use Terminal To Measure Wi-Fi Strength</title>
		<link>http://www.mactricksandtips.com/2010/06/use-terminal-to-measure-wi-fi-strength.html</link>
		<comments>http://www.mactricksandtips.com/2010/06/use-terminal-to-measure-wi-fi-strength.html#comments</comments>
		<pubDate>Mon, 28 Jun 2010 19:31:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1776</guid>
		<description><![CDATA[There is a lot of power available in Terminal, and if used correctly you can create some really interesting scripts and result. Today's post is going to take advantage of some built in Airport frameworks to measure the strength of your connected Wi-Fi signal. Although you can download and use various different apps to do this, if you want a quick way measure the signal, to find the best place to put your laptop, or integrate into something like GeekTool. A quick Terminal script is what you need.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/06/use-terminal-to-measure-wi-fi-strength.html">Use Terminal To Measure Wi-Fi Strength</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/08/five-quick-terminal-tips.html' rel='bookmark' title='Permanent Link: Five Quick Terminal Tips'>Five Quick Terminal Tips</a></li>
<li><a href='http://www.mactricksandtips.com/2008/07/view-terminal-help-pages-online.html' rel='bookmark' title='Permanent Link: View Terminal Help Pages Online'>View Terminal Help Pages Online</a></li>
<li><a href='http://www.mactricksandtips.com/2008/10/start-time-machine-backups-from-terminal.html' rel='bookmark' title='Permanent Link: Start Time Machine Backups From Terminal'>Start Time Machine Backups From Terminal</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Good Evening,</p>
<p>There is a lot of power available in Terminal, and if used correctly you can create some really interesting scripts and result. Today&#8217;s post is going to take advantage of some built in Airport frameworks to measure the strength of your connected Wi-Fi signal. Although you can download and use various different apps to do this, if you want a quick way measure the signal, to find the best place to put your laptop, or integrate into something like <a href="http://projects.tynsoe.org/en/geektool/">GeekTool</a>. A quick Terminal script is what you need.</p>
<p>Your make is built up on various frameworks, essentially build in blocks. Within these building blocks your Mac has all of the usual features you see and use. However select frameworks allow you to extract certain bits of information. This is exactly what we are going to do, to measure signal strength. To do this open Terminal and type the following.</p>
<p><code>/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I</code></p>
<p>You have to be connected to a Wireless signal. The output will look similar to the following:</p>
<p><code>agrCtlRSSI: -69<br />
agrExtRSSI: 0<br />
agrCtlNoise: -96<br />
agrExtNoise: 0<br />
state: running<br />
op mode: station<br />
lastTxRate: 48<br />
maxRate: 54<br />
lastAssocStatus: 0<br />
802.11 auth: open<br />
link auth: none<br />
BSSID: 0:11:11:11:11:11<br />
SSID: DLINK_WIRELESS<br />
MCS: -1<br />
channel: 6</code></p>
<p>Most of the data is self explanatory. &#8216;agrCtlRSSI&#8217; is the signal strength, we will want to get this as high as possible. This is the value we will use later on, &#8216;agrCtlNoise&#8217; is the noise on your Wi-Fi signal you want this as low as possible. Finally, &#8216;maxRate&#8217; is the maximum rate at which your Wi-Fi signal can run at, and &#8216;lastTxRate&#8217; is the last transmitted rate. These two values will probably not change.</p>
<p>If you are interested you can also use this Terminal command to scan the airwaves for other Wi-Fi signals to connect to.</p>
<p><code>/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s</code></p>
<h4>A Live Scanner</h4>
<p>At the moment, using the first command to find the best signal is a bit bulky. The amount of information returned is too much. By placing it into a little loop and picking the right bit of information, it will return just the signal strength. As a result the information returned can easily be used to pick the right spot for your laptop. You simply walk around with your laptop and watch as the signal will rise and fall. [via <a rel="nofollow" href="http://www.macosxhints.com/article.php?story=20100405162603767">macosxhints</a>]<br />
<code><br />
while x=1; do /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep CtlRSSI; sleep 0.5; done</code></p>
<p>This little script will query the Airport as previously mentioned and pull out the signal strength part. Every half a second it will repeat. The results will look something like the following:</p>
<p><code>agrCtlRSSI: -69<br />
agrCtlRSSI: -69<br />
agrCtlRSSI: -70<br />
agrCtlRSSI: -71</code></p>
<p>If you want the list to populate quicker, change 0.5 to something smaller. If you want a longer pause between the lines updating put in a higher value. To stop the output press Control + C and you be returned to the command line. If you want to view the noise associated with the Wi-Fi signal, type the following:<br />
<code><br />
while x=1; do /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep CtlNoise; sleep 0.1; done</code></p>
<p>Very useful and very interesting. If you want to use the command line in a different bash script or in something like GeekTool you only need to type the following.</p>
<p><code>/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport  -I | grep CtlRSSI</code></p>
<p>There you go. Have a play around and see where to place your laptop for the best Wi-Fi result. Its a simple command but very useful. If you have any comments or tips relating to this command please let me know in the comments. If you are interested in reading more about Wi-Fi I recommend <a href="http://www.amazon.com/gp/product/1593271697?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1593271697">The Book of Wireless</a> from Amazon.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/06/use-terminal-to-measure-wi-fi-strength.html">Use Terminal To Measure Wi-Fi Strength</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/08/five-quick-terminal-tips.html' rel='bookmark' title='Permanent Link: Five Quick Terminal Tips'>Five Quick Terminal Tips</a></li>
<li><a href='http://www.mactricksandtips.com/2008/07/view-terminal-help-pages-online.html' rel='bookmark' title='Permanent Link: View Terminal Help Pages Online'>View Terminal Help Pages Online</a></li>
<li><a href='http://www.mactricksandtips.com/2008/10/start-time-machine-backups-from-terminal.html' rel='bookmark' title='Permanent Link: Start Time Machine Backups From Terminal'>Start Time Machine Backups From Terminal</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How To Cheat At Scrabble (With Terminal)</title>
		<link>http://www.mactricksandtips.com/2010/06/how-to-cheat-at-scrabble-with-terminal.html</link>
		<comments>http://www.mactricksandtips.com/2010/06/how-to-cheat-at-scrabble-with-terminal.html#comments</comments>
		<pubDate>Sun, 27 Jun 2010 12:56:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1774</guid>
		<description><![CDATA[I enjoy a good board game every so often, they are even more fun when you can play them online or as a standalone game. The one game, however, that I can never really play is Scrabble. Simply because I can't figure out words from the 7 tiles given to you. The best I can do is five letter words, swear words and adding the occasional 's' or 'ed' to the end of the words. What I need is a way to cheat, or at least give me a helping hand. As the title of this post suggests there is a very simple and effective way to do this using some commands and files built into Terminal.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/06/how-to-cheat-at-scrabble-with-terminal.html">How To Cheat At Scrabble (With Terminal)</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2009/06/mac-cheat-sheet.html' rel='bookmark' title='Permanent Link: Mac Cheat Sheet'>Mac Cheat Sheet</a></li>
<li><a href='http://www.mactricksandtips.com/2009/06/create-a-crossword-solver.html' rel='bookmark' title='Permanent Link: Create A Crossword Solver'>Create A Crossword Solver</a></li>
<li><a href='http://www.mactricksandtips.com/2009/08/cheat-sheets-finding-shortcuts-noob2pro-26.html' rel='bookmark' title='Permanent Link: Cheat Sheets, Finding Shortcuts &#8211; Noob2Pro #26'>Cheat Sheets, Finding Shortcuts &#8211; Noob2Pro #26</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>I enjoy a good board game every so often, they are even more fun when you can play them online or as a standalone game. The one game, however, that I can never really play is <a href="http://www.amazon.com/gp/product/B00000IWDB?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B00000IWDB">Scrabble</a>. Simply because I can&#8217;t figure out words from the 7 tiles given to you. The best I can do is five letter words, swear words and adding the occasional &#8216;s&#8217; or &#8216;ed&#8217; to the end of the words. What I need is a way to cheat, or at least give me a helping hand. As the title of this post suggests there is a very simple and effective way to do this using some commands and files built into Terminal.</p>
<p>The simplest way to cheat at scrabble is to use a word list with plenty of words and then query that list to look for words containing certain letters. There are many ways you can do this and you may develop your own solution, the method I have found is to use a Terminal command called &#8216;grep&#8217; which finds lines containing a pattern, exactly what we need.</p>
<p>To use this command open Terminal and type the following:</p>
<p><code>cd /usr/share/dict<br />
</code><br />
This will change the directory of your current Terminal session. What has been opened is the location of a built in list of words, i&#8217;ve mentioned it before <a href="http://www.mactricksandtips.com/2008/07/location-of-your-words-file.html">here</a>. This list is very long and contains thousands of entries. Although some entries wont be suitable words in Scrabble, it&#8217;s a good place to start. If you have a better list of words (such as one downloaded from the internet) you can use the &#8216;cd&#8217; command and change it to that directory.</p>
<p>To search this list type the following:</p>
<p><code>grep -x '[ahegilk]*' web2</code></p>
<p>This command uses the grep program to search through the words file called &#8216;web2&#8242;. The option, -x, makes sure it only matches words which contain the letters within the square brackets. The letters within the square brackets will be searched and found within the words list. The better  your words list, the more words you can find, the words list built into your Mac is sufficient, for most words and games. Simply replace the letters in the square brackets with the ones you currently have.</p>
<p>Its worth noting at this point that the star at the end of the square brackets will try and match the letters zero or more times. As a result you may get results where the same letter is repeated multiple times, but you only have one letter to use. You could get round this problem by replacing the star with a question mark, an only allow the letters to appear once. However this doesn&#8217;t seem to work on my Mac.</p>
<p>Having a list of words is fine, however in Scrabble you have to add the words onto the board, you need to control how the word starts or ends. This is very simple. To make sure the list only finds words that begin with certain letters, type the following:</p>
<p><code>grep -x '^be[ahegilk]*' web2</code></p>
<p>This will find words that contain the letters &#8216;a h e g i l k&#8217; but begins with &#8216;be&#8217;. The letters at the beginning can be any length, however one or two letters yeild the best results.</p>
<p>You can also search for words that end with certain letters. This, again, is simple. Simply type the following:</p>
<p><code>grep -x '[ahegilk]*ed$' web2</code></p>
<p>This will find all the words that end with &#8216;ed&#8217;. Its worth noting that depending on your words file this will yield different results. I know that the words file built into your Mac, that we are using, doesn&#8217;t have many words ending in &#8216;s&#8217; or &#8216;ed&#8217;, so it isn&#8217;t that useful. If you have found a bumper words file you may have better luck.</p>
<p>You can combine both commands so you can find words that start and end with a certain letter.</p>
<p><code>grep -x '^h[ahegilk]*ed$' web2</code></p>
<p>Very simple and quite useful if you are stuck for words. It does have some limitations such as a limited words file, or repeated letters, but its a simple and quick way to find some words if you are stuck.</p>
<p>If you have found any ways to improve this script, please let me know. I would like to see how this script can evolve and change. With a bit of work it shouldn&#8217;t take too long to make a command to find some really long and high scoring words. It may be cheating, but I still end up losing.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/06/how-to-cheat-at-scrabble-with-terminal.html">How To Cheat At Scrabble (With Terminal)</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2009/06/mac-cheat-sheet.html' rel='bookmark' title='Permanent Link: Mac Cheat Sheet'>Mac Cheat Sheet</a></li>
<li><a href='http://www.mactricksandtips.com/2009/06/create-a-crossword-solver.html' rel='bookmark' title='Permanent Link: Create A Crossword Solver'>Create A Crossword Solver</a></li>
<li><a href='http://www.mactricksandtips.com/2009/08/cheat-sheets-finding-shortcuts-noob2pro-26.html' rel='bookmark' title='Permanent Link: Cheat Sheets, Finding Shortcuts &#8211; Noob2Pro #26'>Cheat Sheets, Finding Shortcuts &#8211; Noob2Pro #26</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting Files In Terminal (Including Docx)</title>
		<link>http://www.mactricksandtips.com/2010/06/converting-files-in-terminal-including-docx.html</link>
		<comments>http://www.mactricksandtips.com/2010/06/converting-files-in-terminal-including-docx.html#comments</comments>
		<pubDate>Sat, 26 Jun 2010 10:21:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1772</guid>
		<description><![CDATA[Quite a while ago I mentioned how you can convert Windows Docx  files to Doc using a little app supplied by Microsoft themselves, its a simple way of saving money and not having to fork out for Office for Mac. That app is great for one or two files that you want to convert, however if you have hundreds of files or want to build this functionality into a bash script it can be a little bit difficult. However there is a suitable Terminal program that you can use. This script piggy backs on the functionality built into TextEdit, so any results you get from TextEdit you will see in this Terminal program.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/06/converting-files-in-terminal-including-docx.html">Converting Files In Terminal (Including Docx)</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/01/converting-windows-docx-files-to-doc.html' rel='bookmark' title='Permanent Link: Converting Windows Docx Files To Doc'>Converting Windows Docx Files To Doc</a></li>
<li><a href='http://www.mactricksandtips.com/2010/04/opening-terminal-files-in-a-different-app.html' rel='bookmark' title='Permanent Link: Opening Terminal Files In A Different App'>Opening Terminal Files In A Different App</a></li>
<li><a href='http://www.mactricksandtips.com/2009/07/converting-movie-files-quickly-and-easily.html' rel='bookmark' title='Permanent Link: Converting Movie Files Quickly And Easily'>Converting Movie Files Quickly And Easily</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Good Morning,</p>
<p>Quite a while ago I mentioned how you can convert <a href="http://www.mactricksandtips.com/2010/01/converting-windows-docx-files-to-doc.html">Windows Docx files to Doc</a> using a little app supplied by Microsoft themselves, its a simple way of saving money and not having to fork out for <a href="http://www.amazon.com/gp/product/B000X86ZAS?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B000X86ZAS">Office for Mac</a>. That app is great for one or two files that you want to convert, however if you have hundreds of files or want to build this functionality into a bash script it can be a little bit difficult. However there is a suitable Terminal program that you can use. This script piggy backs on the functionality built into TextEdit, so any results you get from TextEdit you will see in this Terminal program.</p>
<p>The function we are going to use is textutil. As you may guess by the name it is a text utility. The program has many functions and you can find out how to use them all by reading the man page (in Terminal type &#8216;man textutil&#8217;), i&#8217;m going to focus, however, on the conversion aspect of the program. In this example I am going to convert a docx file to a doc file. In total you can use any of these format txt, rtf, rtfd, html, doc, docx, odt, wordml, or webarchive.</p>
<p>To convert a file type the following in Terminal:</p>
<p><code>textutil -convert doc /path/to/my/file.docx</code></p>
<p>This will convert the file from docx to doc. The result will be exactly the same if you used TextEdit to open the file and save it out. For example i&#8217;ve found any docx images won&#8217;t appear in the final doc format, if you want the images its better to use the little app supplied by Microsoft. Simply change &#8216;doc&#8217; into the format you are looking for. If you don&#8217;t think it will work, try the file extension and see what happens.</p>
<p>If you want to convert all of the files in a folder to one format you can type<br />
<code><br />
textutil -convert doc /path/to/location/*.docx</code></p>
<p>This will convert every file in the folder with .docx as the the file type into the doc format. This is a very quick way of converting lots of files.</p>
<p>There is a lot of power with this tool. If you want to learn more about the program, use the man page as mentioned, if you have a cool little tip about this function please leave a comment below.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/06/converting-files-in-terminal-including-docx.html">Converting Files In Terminal (Including Docx)</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/01/converting-windows-docx-files-to-doc.html' rel='bookmark' title='Permanent Link: Converting Windows Docx Files To Doc'>Converting Windows Docx Files To Doc</a></li>
<li><a href='http://www.mactricksandtips.com/2010/04/opening-terminal-files-in-a-different-app.html' rel='bookmark' title='Permanent Link: Opening Terminal Files In A Different App'>Opening Terminal Files In A Different App</a></li>
<li><a href='http://www.mactricksandtips.com/2009/07/converting-movie-files-quickly-and-easily.html' rel='bookmark' title='Permanent Link: Converting Movie Files Quickly And Easily'>Converting Movie Files Quickly And Easily</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hide Select Icons From View (incl Hard Drives)</title>
		<link>http://www.mactricksandtips.com/2010/06/hide-select-icons-from-view-incl-hard-drives.html</link>
		<comments>http://www.mactricksandtips.com/2010/06/hide-select-icons-from-view-incl-hard-drives.html#comments</comments>
		<pubDate>Wed, 23 Jun 2010 18:00:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1763</guid>
		<description><![CDATA[Continuing from a post a couple of days ago about Hiding Hard Drive Icons From Your Desktop and reading into an insight full comment i've found a method where you can hide certain hard drive, folders and files from view. A quick method is to normally add a dot in front of the file name so it becomes a "dot-file" for example ".hiddenfile.txt". This will make the file disappear from view. However this changes the file name and if you have any scripts or applications that rely on the exact file name this can be a problem, it can be even worst when you want to remove a Hard Drive, change the file name of such a volume can be disastrous. Therefore we are going to play around with a couple of Terminal programs to change the attributes of files, folders and even Hard Drives so we can hide them from view.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/06/hide-select-icons-from-view-incl-hard-drives.html">Hide Select Icons From View (incl Hard Drives)</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/01/solving-minor-problems-incl-crashes-in-apps.html' rel='bookmark' title='Permanent Link: Solving Minor Problems (incl Crashes) In Apps'>Solving Minor Problems (incl Crashes) In Apps</a></li>
<li><a href='http://www.mactricksandtips.com/2009/03/only-select-certain-parts-of-text.html' rel='bookmark' title='Permanent Link: Only Select Certain Parts Of Text'>Only Select Certain Parts Of Text</a></li>
<li><a href='http://www.mactricksandtips.com/2009/07/hide-the-menubar-or-dock-in-specific-apps.html' rel='bookmark' title='Permanent Link: Hide The MenuBar or Dock In Specific Apps'>Hide The MenuBar or Dock In Specific Apps</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>Continuing from a post a couple of days ago about <a href="http://www.mactricksandtips.com/2010/06/hiding-hard-drive-icons-from-your-desktop.html">Hiding Hard Drive Icons From Your Desktop</a> and reading into an insight full comment i&#8217;ve found a method where you can hide certain hard drive, folders and files from view. A quick method is to normally add a dot in front of the file name so it becomes a &#8220;dot-file&#8221; for example &#8220;.hiddenfile.txt&#8221;. This will make the file disappear from view. However this changes the file name and if you have any scripts or applications that rely on the exact file name this can be a problem, it can be even worst when you want to remove a Hard Drive, change the file name of such a volume can be disastrous. Therefore we are going to play around with a couple of Terminal programs to change the attributes of files, folders and even Hard Drives so we can hide them from view.</p>
<p>Before we start you need to have the developer tools installed. Since we use two special Terminal files that get installed when the developer tools are installed. To install the tools simply  insert your installation disk that comes with your Mac or follow this post on <a href="http://www.mactricksandtips.com/2010/02/installing-xcode.html">Installing XCode</a>. I would just post the two files needed, however I don&#8217;t have the right to distribute them.</p>
<p>Once the developer tools are installed we are ready to go. We are going to use two Terminal programs, GetFileInfo and SetFile. The first is used to see the file attributes the second to change them. We are going to change the file attributes so it is hidden. First off open up Terminal under Utilities and type the following, we are going to hide a BootCamp partition, although it can be applied to any file, folder or disk.</p>
<p><code>GetFileInfo /Volumes/BOOTCAMP</code></p>
<p>It will post results similar to the following.</p>
<p><code>directory: "/Volumes/BOOTCAMP"<br />
attributes: avbstclinmedz<br />
created: 01/01/1904 00:00:00<br />
modified: 06/23/2010 13:59:22</code></p>
<p>The second line is something that we are interested in. It has a line of attributes that we can change, although the letters are meaningless at this point they each represent something that can be changed, we are going to change the visibility attribute so it disappears. In Terminal again, type the following.</p>
<p><code>sudo SetFile -a V /Volumes/BOOTCAMP</code></p>
<p>This uses the SetFile program to change the attribute setting (-a) to invisible &#8220;V&#8221;, for the Volume BOOTCAMP, change the string at the end to anything you want. Use the full path to the file to make sure you don&#8217;t hide anything you don&#8217;t want.</p>
<p>After a quick moment the hard drive or anything you are hiding is gone. It wont be visible in Finder, but is still there with the original file name. If you are hiding a hard drive and a hard drive icon with the name &#8220;client node&#8221; appear, simply log off and back on again for it to disappear. I don&#8217;t no what it is, but it is relatively harmless.</p>
<p>This trick can be done with pretty much anything, i&#8217;ve tested it will files and folders as well and they all disappear. If you want to change anything back so you can see it again, type the following into Terminal.<br />
<code><br />
sudo SetFile -a v /Volumes/BOOTCAMP</code></p>
<p>All that is change is the attribute item &#8220;v&#8221;. Its can from on, to off. If you want to see the different that you can change just type &#8220;SetFile&#8221; into Terminal. Err on the side of caution if you change anything as it may be difficult to revert.</p>
<p>Overall this is a very simple, and quite a useful trick. It could be used to hide your Macintosh hard drive if you have children that like to mess things up. There is quite a few possibilities that can be done with this little program.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/06/hide-select-icons-from-view-incl-hard-drives.html">Hide Select Icons From View (incl Hard Drives)</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/01/solving-minor-problems-incl-crashes-in-apps.html' rel='bookmark' title='Permanent Link: Solving Minor Problems (incl Crashes) In Apps'>Solving Minor Problems (incl Crashes) In Apps</a></li>
<li><a href='http://www.mactricksandtips.com/2009/03/only-select-certain-parts-of-text.html' rel='bookmark' title='Permanent Link: Only Select Certain Parts Of Text'>Only Select Certain Parts Of Text</a></li>
<li><a href='http://www.mactricksandtips.com/2009/07/hide-the-menubar-or-dock-in-specific-apps.html' rel='bookmark' title='Permanent Link: Hide The MenuBar or Dock In Specific Apps'>Hide The MenuBar or Dock In Specific Apps</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Opening Terminal Files In A Different App</title>
		<link>http://www.mactricksandtips.com/2010/04/opening-terminal-files-in-a-different-app.html</link>
		<comments>http://www.mactricksandtips.com/2010/04/opening-terminal-files-in-a-different-app.html#comments</comments>
		<pubDate>Mon, 05 Apr 2010 18:12:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1738</guid>
		<description><![CDATA[I hope you all had a good weekend and Easter. Today's post is going to be a small follow on to Saturday's post on editing your Bash profile. One of the comments gave me an idea of allowing you to open the file in TextEdit and edit the file from there, rather than trying to use Terminals built in file editor. I am going to expand on this and show you how to open a file from Terminal so you can edit in a different app. This is useful since you don't have to fight with Terminal's text editors, especially if you have limited knowledge of the workings or don't like to use them.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/04/opening-terminal-files-in-a-different-app.html">Opening Terminal Files In A Different App</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/06/converting-files-in-terminal-including-docx.html' rel='bookmark' title='Permanent Link: Converting Files In Terminal (Including Docx)'>Converting Files In Terminal (Including Docx)</a></li>
<li><a href='http://www.mactricksandtips.com/2009/07/peek-into-zip-files-with-terminal.html' rel='bookmark' title='Permanent Link: Peek Into Zip Files With Terminal'>Peek Into Zip Files With Terminal</a></li>
<li><a href='http://www.mactricksandtips.com/2008/07/make-quick-multi-file-files-w-terminal.html' rel='bookmark' title='Permanent Link: Make Quick Multi File Files w/ Terminal'>Make Quick Multi File Files w/ Terminal</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>I hope you all had a good weekend and Easter. Today&#8217;s post is going to be a small follow on to Saturday&#8217;s post on <a href="http://www.mactricksandtips.com/2010/04/create-your-own-custom-terminal-commands.html">editing your Bash profile</a>. One of the comments gave me an idea of allowing you to open the file in TextEdit and edit the file from there, rather than trying to use Terminals built in file editor. I am going to expand on this and show you how to open a file from Terminal so you can edit in a different app. This is useful since you don&#8217;t have to fight with Terminal&#8217;s text editors, especially if you have limited knowledge of the workings or don&#8217;t like to use them.</p>
<p>Opening files is very simple. Within Terminal the function to open a file is called <code>open</code>. In guessing for why they picked that name. The Terminal program can be used in various different ways, for example the following:</p>
<p><code>open file.txt</code></p>
<p>Will open the file in TextEdit. If you want to apply this to the file in the previous post you can write:</p>
<p><code>open .bash_profile</code></p>
<p>Here you can edit the file in TextEdit, which makes life a lot easier.</p>
<p>You can also use the open program on a whole load of other file types. The following will work perfectly well, the last one will open a Finder window to a location instead of a file in an app.</p>
<p><code>open http://www.mactricksandtips.com</code></p>
<p><code>open image.jpg</code></p>
<p><code>open /path/to/folder</code></p>
<p>Each one will open the file, and URL&#8217;s, in the default app as supplied by your operating system. If you want to change which app it opens with you can modify how the app works. This is done with the following command.</p>
<p><code>open -a "/Applications/TextMate.app" text.txt</code></p>
<p>The &#8220;-a&#8221; command says &#8220;use this program instead&#8221;. Make sure when you list the file path you give the .app file extension (which is always present, just hidden) otherwise you will get an error.</p>
<p>If you want to open the program in the background use the -g option as such:</p>
<p><code>open -g text.txt<br />
</code><br />
Finally, instead of opening the file you can show it in Finder. This only works if you can already see the file, if the file is hidden (i.e starts with a dot) you just get the Finder window.</p>
<p><code>open -R /path/to/file/file.txt</code></p>
<p>Overall the program is very useful, and I will begin to use it to edit files. I haven&#8217;t tested this however I have a feeling if you add &#8220;sudo&#8221; to the front of the command you will be able to edit files that you would normally need a password for. Try it out and see what happens. If you want more information on this command simply type &#8220;man open&#8221; into Terminal, there is a couple of other bits of information, the important bits are listed here.</p>
<p>If you have any questions or comments please leave them below.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/04/opening-terminal-files-in-a-different-app.html">Opening Terminal Files In A Different App</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/06/converting-files-in-terminal-including-docx.html' rel='bookmark' title='Permanent Link: Converting Files In Terminal (Including Docx)'>Converting Files In Terminal (Including Docx)</a></li>
<li><a href='http://www.mactricksandtips.com/2009/07/peek-into-zip-files-with-terminal.html' rel='bookmark' title='Permanent Link: Peek Into Zip Files With Terminal'>Peek Into Zip Files With Terminal</a></li>
<li><a href='http://www.mactricksandtips.com/2008/07/make-quick-multi-file-files-w-terminal.html' rel='bookmark' title='Permanent Link: Make Quick Multi File Files w/ Terminal'>Make Quick Multi File Files w/ Terminal</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Create Your Own Custom Terminal Commands</title>
		<link>http://www.mactricksandtips.com/2010/04/create-your-own-custom-terminal-commands.html</link>
		<comments>http://www.mactricksandtips.com/2010/04/create-your-own-custom-terminal-commands.html#comments</comments>
		<pubDate>Sat, 03 Apr 2010 20:43:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1736</guid>
		<description><![CDATA[The title of this post is a little misleading, what we are going to do today is develop our own Bash command to work in Terminal to allow use to do simple, repetitive commands, with only a couple of keys. Think of they as macros, a simple and easy way to cut down time. This doesn't take long and it can be powerful, and like anything in life it just takes a little bit of know how. This tutorial is great if you have a specific folder which you visit again, or a Terminal command you run frequently. For example I have one where I type "hits" to get the current number of connections to my site, the actual code to do this is a bit long.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/04/create-your-own-custom-terminal-commands.html">Create Your Own Custom Terminal Commands</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2012/02/loop-repeat-terminal-commands.html' rel='bookmark' title='Permanent Link: Loop / Repeat Terminal Commands'>Loop / Repeat Terminal Commands</a></li>
<li><a href='http://www.mactricksandtips.com/2008/09/print-selected-information-from-terminal-commands.html' rel='bookmark' title='Permanent Link: Print Selected Info From Terminal Commands'>Print Selected Info From Terminal Commands</a></li>
<li><a href='http://www.mactricksandtips.com/2008/02/create-graphical-view-of-subfolders-in.html' rel='bookmark' title='Permanent Link: Create Graphical View Of Folders In Terminal'>Create Graphical View Of Folders In Terminal</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>The title of this post is a little misleading, what we are going to do today is develop our own Bash command to work in Terminal to allow use to do simple, repetitive commands, with only a couple of keys. Think of they as macros, a simple and easy way to cut down time. This doesn&#8217;t take long and it can be powerful, and like anything in life it just takes a little bit of know how. This tutorial is great if you have a specific folder which you visit again, or a Terminal command you run frequently. For example I have one where I type &#8220;hits&#8221; to get the current number of connections to my site, the actual code to do this is a bit long.</p>
<p>First things first open Terminal in Applications &gt; Utilities. Then type ls -a you should see a lot of files. Depending on the version you use you should see a file called either &#8220;.bash_profile&#8221; or &#8220;.profile&#8221;, remember which is one is present. If none are present it doesn&#8217;t matter. Then type <code>nano .bash_profile</code> into Terminal to open up a text editor. If &#8220;.profile&#8221; is there try <code>nano .profile</code>. It is probably worth saying now, if this doesn&#8217;t work with one file name, try the other. I&#8217;ve read various different tutorials, all referencing a different file. My bet is on &#8220;.bash_profile&#8221; if you are on Mac OS X 10.5/6.</p>
<p>This file controls some of the aspects on how Bash works. Bash is the program that runs within Terminal, there are other ones but we wont get into that. What we are going to write is a macro/function/what-ever-you-want-to-call-it which will run hen the command is typed. Your bash profile may have some text in it already so scroll down to the bottom with the arrow keys if it has. Then write the following:</p>
<p><code>test(){</code></p>
<p>This is the beginning of our code. It will run when we write test into Terminal. Then write the following on a new line (change it as you wish).</p>
<p><code>cd /Users/[name]/Desktop<br />
}</code></p>
<p>Change [name] to your name, or change the whole path to something you know exists. Make sure the closing curly brackets is on a new line. To finish press Control + O. Your changes will now be committed. To test them open a new Terminal window by pressing Command + N, and type test into the Terminal prompt. If everything goes to plan, the new directory will be picked. By opening a new window you can test any changes while still having the original text editor open. Any errors will be at the top of the Terminal prompt when you open a new window.</p>
<p>Now you have the workings we can make things more interesting. Anything on the &#8220;cd /Users&#8230;&#8221; line change be changed to anything you want. You can have more than one command by ending them in a semi-colon and putting the second command on a new line. Always make sure that the curly bracket is on a new line and the name you give is unique.</p>
<p>If you want to make things a little bit more complicated you can. In the next example I am going to use a variable. Variables are represented by &#8220;$1&#8243;. For example the following:</p>
<p><code>test2(){<br />
cd /Users/"$1"<br />
}</code></p>
<p>Will work when you type into Terminal:</p>
<p><code>test2 James</code></p>
<p>The first word after &#8220;test2&#8243; will take the place of the $1 symbol. You can add more than one variable as such.</p>
<p><code>test2(){<br />
cd /Users/"$1"/"$2"<br />
}</code></p>
<p>So:</p>
<p><code>test2 James Desktop</code></p>
<p>Will result in Terminal in terminal changing the directory to my Desktop. The variables can appear any number of times, just put them in speak marks.</p>
<p>Have a play around with the commands, over time they will be come more complex. If you want to remove anyone simply delete the entry. To close the text editor press Control + X. Note changes you make will only take effect when a new Terminal prompt it open.</p>
<p>If you want to learn more there is hundreds of books around. Simply google &#8220;Bash Programming&#8221;, or check out some books in Amazon, some good ones include <a href="http://www.amazon.com/gp/product/1430219971?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1430219971">Pro Bash Programming</a>, <a href="http://www.amazon.com/gp/product/0596009658?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0596009658">Learning the bash Shell</a>, <a href="http://www.amazon.com/gp/product/0596526784?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0596526784">Bash Cookbook</a> or any <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2Fs%3Fie%3DUTF8%26x%3D0%26ref_%3Dnb%5Fsb%5Fss%5Fi%5F0%5F9%26y%3D0%26field-keywords%3Dbash%2520programming%26url%3Dsearch-alias%253Daps%26sprefix%3Dbash%2520prog&amp;tag=mact06-20&amp;linkCode=ur2&amp;camp=1789&amp;creative=390957">bash programming</a> on Amazon.</p>
<p>If you have any questions or comments please leave one below.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/04/create-your-own-custom-terminal-commands.html">Create Your Own Custom Terminal Commands</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2012/02/loop-repeat-terminal-commands.html' rel='bookmark' title='Permanent Link: Loop / Repeat Terminal Commands'>Loop / Repeat Terminal Commands</a></li>
<li><a href='http://www.mactricksandtips.com/2008/09/print-selected-information-from-terminal-commands.html' rel='bookmark' title='Permanent Link: Print Selected Info From Terminal Commands'>Print Selected Info From Terminal Commands</a></li>
<li><a href='http://www.mactricksandtips.com/2008/02/create-graphical-view-of-subfolders-in.html' rel='bookmark' title='Permanent Link: Create Graphical View Of Folders In Terminal'>Create Graphical View Of Folders In Terminal</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Disable Quarantine Msg When Downloading Files</title>
		<link>http://www.mactricksandtips.com/2010/03/disable-quarantine-msg-when-downloading-files.html</link>
		<comments>http://www.mactricksandtips.com/2010/03/disable-quarantine-msg-when-downloading-files.html#comments</comments>
		<pubDate>Mon, 22 Mar 2010 16:55:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1714</guid>
		<description><![CDATA[When you download files in Firefox and Safari and then open them you will get a message asking you if you want to open the file. It goes along the line of  '"Example" is an application you have downloaded from the internet, are you sure you want to open it', with various options. Its designed as a message barrier to stop you opening malicious files that could harm your Mac. The problem I have is that its a bit annoying and I know what I am downloading, if only there was some way of disabling this message. Thankfully there is, and like may commands to change preferences it is a one liner and only takes a couple of moments.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/03/disable-quarantine-msg-when-downloading-files.html">Disable Quarantine Msg When Downloading Files</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2009/06/disable-dock-bouncing.html' rel='bookmark' title='Permanent Link: Disable Dock Bouncing'>Disable Dock Bouncing</a></li>
<li><a href='http://www.mactricksandtips.com/2008/10/disable-data-decetors-in-mail.html' rel='bookmark' title='Permanent Link: Disable Data Detectors In Mail'>Disable Data Detectors In Mail</a></li>
<li><a href='http://www.mactricksandtips.com/2008/06/disable-your-network-connections.html' rel='bookmark' title='Permanent Link: Disable Your Network Connections'>Disable Your Network Connections</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>When you download files in Firefox and Safari and then open them you will get a message asking you if you want to open the file. It goes along the line of  &#8216;&#8221;Example&#8221; is an application you have downloaded from the internet, are you sure you want to open it&#8217;, with various options. Its designed as a message barrier to stop you opening malicious files that could harm your Mac. The problem I have is that its a bit annoying and I know what I am downloading, if only there was some way of disabling this message. Thankfully there is, and like may commands to change preferences it is a one liner and only takes a couple of moments.</p>
<p><img class="aligncenter size-medium wp-image-1715" title="APPLE quarantine" src="http://www.mactricksandtips.com/wp-content/uploads/2010/03/APPLE-quarantine-300x127.png" alt="APPLE quarantine" width="300" height="127" /></p>
<p>To remove the message, open up Terminal in the Applications &gt; Utilities folder, then copy and paste the following.</p>
<p><code>defaults write com.apple.LaunchServices LSQuarantine -bool NO</code></p>
<p>Then restart your Mac. If you download an app or other file that triggers the warning you should notice that the message no longer appears. The only problem with this tips is that you are removing a layer of security, but you can always click on Open in the original message, which reduces its effectiveness.</p>
<p>If you ever want to revert the process copy and paste the following into Terminal and hit enter.</p>
<p><code>defaults write com.apple.LaunchServices LSQuarantine -bool YES</code></p>
<p>Once again, restart your Mac and the changes should take effect. I&#8217;ve not tested this second command, I assume it will work.</p>
<p>If you have any questions or comments please leave a comment below.</p>
<p>Via <a href="http://www.macosxhints.com/article.php?story=20091208050655947" rel="nofollow">MacOSXHints</a></p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/03/disable-quarantine-msg-when-downloading-files.html">Disable Quarantine Msg When Downloading Files</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2009/06/disable-dock-bouncing.html' rel='bookmark' title='Permanent Link: Disable Dock Bouncing'>Disable Dock Bouncing</a></li>
<li><a href='http://www.mactricksandtips.com/2008/10/disable-data-decetors-in-mail.html' rel='bookmark' title='Permanent Link: Disable Data Detectors In Mail'>Disable Data Detectors In Mail</a></li>
<li><a href='http://www.mactricksandtips.com/2008/06/disable-your-network-connections.html' rel='bookmark' title='Permanent Link: Disable Your Network Connections'>Disable Your Network Connections</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>See Which Apps Are Using The Net With Terminal</title>
		<link>http://www.mactricksandtips.com/2010/02/see-which-apps-are-using-the-net-with-terminal.html</link>
		<comments>http://www.mactricksandtips.com/2010/02/see-which-apps-are-using-the-net-with-terminal.html#comments</comments>
		<pubDate>Tue, 16 Feb 2010 21:43:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1682</guid>
		<description><![CDATA[A while ago I mentioned about monitoring your Internet connections with Little Snitch. Little Snitch is quite a complex application which allows you to block and allow certain connections, it also allows you to see which applications are connection to theInternet . Since the application does cost money after the demo you may be looking for a "free" version. Today I am going to explain a cool Terminal command which you can use to see which applications have connected to the Internet or your local connection in the last few minutes. <p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/02/see-which-apps-are-using-the-net-with-terminal.html">See Which Apps Are Using The Net With Terminal</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2009/04/close-apps-after-a-period-of-time.html' rel='bookmark' title='Permanent Link: Close Apps After A Period Of Time'>Close Apps After A Period Of Time</a></li>
<li><a href='http://www.mactricksandtips.com/2008/08/solving-cpu-intensive-applications.html' rel='bookmark' title='Permanent Link: Solving CPU Intensive Apps'>Solving CPU Intensive Apps</a></li>
<li><a href='http://www.mactricksandtips.com/2008/07/must-have-default-installed-apps.html' rel='bookmark' title='Permanent Link: Must Have Default Installed Apps'>Must Have Default Installed Apps</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Evening,</p>
<p>A while ago I mentioned about <a href="http://www.mactricksandtips.com/2008/03/monitor-your-network-connections.html">monitoring your Internet connections</a> with <a href="http://www.obdev.at/products/littlesnitch/index.html">Little Snitch</a>. Little Snitch is quite a complex application which allows you to block and allow certain connections, it also allows you to see which applications are connection to the Internet. Since the application does cost money after the demo you may be looking for a &#8220;free&#8221; version. Today I am going to explain a cool Terminal command which you can use to see which applications have connected to the Internet or your local connection in the last few minutes.</p>
<p>The first step is to open up Terminal. This is found in Applications &gt; Utilities. When the app is open, copy and paste the following and hit enter.</p>
<p><code>lsof -P -i -n | cut -f 1 -d " " | uniq</code></p>
<p>When the code runs it will display a list of all of the applications which have connected to the Internet, i&#8217;m not sure how long it looks back but you can be pretty sure which apps have accessed the Internet or your network within the last 5 minutes. This is quite useful if you can see your connection saturated (for example using iStat) and you want to narrow down which application is using it.</p>
<p>The line above is split into three different commands, all which run at the same time. The first command, lsof, lists open files, if your run it on its own the command will list all of the open files which you make is using. The first modifying options, -P, will convert port numbers it is combined with -i, -i is used to list all open files on your network. Together they make it easy to see which apps are using your Internet. The final option, -n, is used to inhibits the conversion of network numbers to host names for network files. Both -P and -n allow the lsof program to run faster. If you run lsof on its own it generates a huge amount of output, so any time saving is appreciated.</p>
<p>The middle part of the code, cut, is used to trim down the result. The option, -f 1 makes sure the input from lsof is being used to cut the data, the -d option sets the delimiter, to choose which parts of the field to cut down. In the brackets the spaces are chosen as the delimiter, as a result anything after the first space will be cut from the result, you can enter values in between the speech marks to change the outputted result . If you run both lsof and cut on its own there will be a repeated list of applications, we now need to reduce this list further.</p>
<p>The final option, uniq, goes through the list, line by line and removes any duplicate bits of data. This cleans up the results and makes them slightly more readable.</p>
<p>Hopefully you understand how this little scripts works. The results aren&#8217;t prefect but they are pretty useful. Have a play around with the options and see what you can do. If you want more information on each section, in Terminal type &#8220;man &#8230;&#8221; replace &#8230; with either lsof, cut or uniq to give you more information. If you have a question or comment please leave one below.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/02/see-which-apps-are-using-the-net-with-terminal.html">See Which Apps Are Using The Net With Terminal</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2009/04/close-apps-after-a-period-of-time.html' rel='bookmark' title='Permanent Link: Close Apps After A Period Of Time'>Close Apps After A Period Of Time</a></li>
<li><a href='http://www.mactricksandtips.com/2008/08/solving-cpu-intensive-applications.html' rel='bookmark' title='Permanent Link: Solving CPU Intensive Apps'>Solving CPU Intensive Apps</a></li>
<li><a href='http://www.mactricksandtips.com/2008/07/must-have-default-installed-apps.html' rel='bookmark' title='Permanent Link: Must Have Default Installed Apps'>Must Have Default Installed Apps</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Disabling Default Auto-Rotate &amp; Scale In Preview</title>
		<link>http://www.mactricksandtips.com/2010/02/disabling-default-auto-rotate-scale-in-preview.html</link>
		<comments>http://www.mactricksandtips.com/2010/02/disabling-default-auto-rotate-scale-in-preview.html#comments</comments>
		<pubDate>Fri, 12 Feb 2010 18:10:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1677</guid>
		<description><![CDATA[Within Preview there are two options when you come to print that you usually take notice of. These are the "Auto-Rotate" and "Scale To Fit", most of the time these options are sufficient for normal work. However, if you work with documents that are always the same or with documents that you don't want to "Auto-Rotate" and scale, since they may be in the correction orientation and anything added just causes problem, you can disable these options. Normally the options preferences are remember throughout the day, and when you open and close Preview. However if you restart your computer you may find that these options reset. This can be a pain, especially if you have to keep removing these options and sometimes forget.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/02/disabling-default-auto-rotate-scale-in-preview.html">Disabling Default Auto-Rotate &#038; Scale In Preview</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/02/change-default-ical-event-length.html' rel='bookmark' title='Permanent Link: Change Default iCal Event Length'>Change Default iCal Event Length</a></li>
<li><a href='http://www.mactricksandtips.com/2012/01/view-terminal-man-pages-in-preview-pdf.html' rel='bookmark' title='Permanent Link: View Terminal &#8216;man&#8217; Pages In Preview / PDF'>View Terminal &#8216;man&#8217; Pages In Preview / PDF</a></li>
<li><a href='http://www.mactricksandtips.com/2008/10/joining-pdf-files-together-in-preview.html' rel='bookmark' title='Permanent Link: Joining PDF Files Together In Preview'>Joining PDF Files Together In Preview</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>Within Preview there are two options when you come to print that you usually take notice of. These are the &#8220;Auto-Rotate&#8221; and &#8220;Scale To Fit&#8221;, most of the time these options are sufficient for normal work. However, if you work with documents that are always the same or with documents that you don&#8217;t want to &#8220;Auto-Rotate&#8221; and scale, since they may be in the correction orientation and anything added just causes problem, you can disable these options. Normally the options preferences are remember throughout the day, and when you open and close Preview. However if you restart your computer you may find that these options reset. This can be a pain, especially if you have to keep removing these options and sometimes forget.</p>
<p><img class="aligncenter size-medium wp-image-1678" title="preview print preferences" src="http://www.mactricksandtips.com/wp-content/uploads/2010/02/preview-print-preferences-300x208.png" alt="preview print preferences" width="300" height="208" /></p>
<p>The image above, with the massive red arrows, shows what I mean. Removing the default is simple. Open Terminal in Applications &gt; Utilities and copy and paste the following:<br />
<code><br />
defaults write com.apple.Preview PVImagePrintingScaleMode 0</code></p>
<p>After hitting enter this will disable the &#8220;Scale To Fit&#8221; option within Preview. You can test the results by restarting Preview.</p>
<p>If you want to disable &#8220;Auto Rotate&#8221;, copy and paste the following into Terminal.</p>
<p><code>defaults write com.apple.Preview PVImagePrintingAutoRotate 0</code></p>
<p>Once again, restart Preview and the results should take effect.</p>
<p>If you want to reset this option simply copy and paste the following code into Terminal.</p>
<p><code>defaults delete com.apple.Preview PVImagePrintingScaleMode;<br />
defaults delete com.apple.Preview PVImagePrintingAutoRotate</code></p>
<p>This will delete the preference files and return Preview to the original state.</p>
<p>A simple trick which I am sure some of you will find useful. This trick works in Snow Leopard, so your mileage may vary with older operating systems. If you want to learn more about Terminal either use the related links below this post. I also recommend <a href="http://www.amazon.com/gp/product/0596153287?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0596153287">Snow Leopard: The Missing Manual</a> and <a href="http://www.amazon.com/gp/product/059652062X?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=059652062X">Mac OS X for Unix Geeks</a>, both are great books.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/02/disabling-default-auto-rotate-scale-in-preview.html">Disabling Default Auto-Rotate &#038; Scale In Preview</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/02/change-default-ical-event-length.html' rel='bookmark' title='Permanent Link: Change Default iCal Event Length'>Change Default iCal Event Length</a></li>
<li><a href='http://www.mactricksandtips.com/2012/01/view-terminal-man-pages-in-preview-pdf.html' rel='bookmark' title='Permanent Link: View Terminal &#8216;man&#8217; Pages In Preview / PDF'>View Terminal &#8216;man&#8217; Pages In Preview / PDF</a></li>
<li><a href='http://www.mactricksandtips.com/2008/10/joining-pdf-files-together-in-preview.html' rel='bookmark' title='Permanent Link: Joining PDF Files Together In Preview'>Joining PDF Files Together In Preview</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Working With The Date Function In Terminal</title>
		<link>http://www.mactricksandtips.com/2010/01/working-with-the-date-function-in-terminal.html</link>
		<comments>http://www.mactricksandtips.com/2010/01/working-with-the-date-function-in-terminal.html#comments</comments>
		<pubDate>Sun, 31 Jan 2010 21:24:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1648</guid>
		<description><![CDATA[Yesterday I wrote a post on the calendar function in Terminal, its designed as a two part series, with the second part being about the date function. I found in bash scripts the two functions sort of work hand in hand. This post is going to show you some of the main features of the date function. The date function is more versatile in that you can easily pick out the piece of information you want, the week of the year, day of the year etc, the calendar function is more graphical. The date function can be used to set the date in your Mac, however I will not be going into this today as I prefer to use System Preferences (to find out more about setting the date use the man help page).<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/01/working-with-the-date-function-in-terminal.html">Working With The Date Function In Terminal</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/01/working-with-the-calendar-function-in-terminal.html' rel='bookmark' title='Permanent Link: Working With The Calendar Function In Terminal'>Working With The Calendar Function In Terminal</a></li>
<li><a href='http://www.mactricksandtips.com/2009/06/back-date-a-file-using-terminal.html' rel='bookmark' title='Permanent Link: Back Date A File Using Terminal'>Back Date A File Using Terminal</a></li>
<li><a href='http://www.mactricksandtips.com/2008/03/inserting-the-date-time.html' rel='bookmark' title='Permanent Link: Inserting The Date &amp; Time'>Inserting The Date &amp; Time</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>Yesterday I wrote a post on the <a href="http://www.mactricksandtips.com/2010/01/working-with-the-calendar-function-in-terminal.html">calendar function in Terminal</a>, its designed as a two part series, with the second part being about the date function. I found in bash scripts the two functions sort of work hand in hand. This post is going to show you some of the main features of the date function. The date function is more versatile in that you can easily pick out the piece of information you want, the week of the year, day of the year etc, the calendar function is more graphical. The date function can be used to set the date in your Mac, however I will not be going into this today as I prefer to use System Preferences (to find out more about setting the date use the man help page).</p>
<p>Before we start I would like to point out a couple of cool books on <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2F&amp;tag=mact06-20&amp;linkCode=ur2&amp;camp=1789&amp;creative=390957" target="_blank">Amazon</a> which may be of use if you want to pursue this type of programming. My favourite is <a href="http://www.amazon.com/gp/product/0470478365?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0470478365">Mac OS X Unix Toolbox</a> although there is a <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2Fs%3Fie%3DUTF8%26x%3D0%26ref_%3Dnb%255Fsb%255Fnoss%26y%3D0%26field-keywords%3Dmac%2520unix%26url%3Dsearch-alias%253Daps&amp;tag=mact06-20&amp;linkCode=ur2&amp;camp=1789&amp;creative=390957">variety</a> on Amazon.</p>
<p>The date function is accessed in Terminal simply by typing <code>date</code> this will display something similar to the following.</p>
<p><code>Sun 31 Jan 2010 20:58:03 GMT</code></p>
<p>That&#8217;s useful on its own. However if you are using a bash script any want something specific the default format displayed by &#8216;date&#8217; is a bit basic. As a result we are going to use some formatting options to pick apart the date function and allow use to display what we want. This is done using the following:</p>
<p><code>date '+%A'</code></p>
<p>The previous code will display the long hand day of the week, eg &#8220;Sunday&#8221;. What is important to note is the %A, these can be a variety of options which I will discuss in a minute. Anything that doesn&#8217;t have an ampersand before the letter will be displayed by text, the single quote marks and the plus sign need to be added otherwise the script will result in an error, any other text added will be displayed in full.</p>
<p>There are a variety of format options which can be used. A more comprehensive list can be found <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?date">here</a>, the best ones are below.</p>
<p>%a = Short date, Sun<br />
%A = Long date, Sunday<br />
%b = Short Month, Feb<br />
%B = Long Month, February<br />
%d = Day of the month<br />
%D = Date such as %m/%d/%y<br />
%H = Hour in 24 hour format (00..23)<br />
%I = Hour in 12 hour format (01..12) (this can be used with %p to append Am or PM)<br />
%j = Day of the year<br />
%m = Month in number format (01..12)<br />
%M = Minute (00..59)<br />
%p = Locale either AM or PM<br />
%S = Second<br />
%u = Day of the week<br />
%V = Week number of year with Monday as first day of week (01..53)<br />
%Y = Year<br />
%z = Numeric timezone (e.g., -0400) or %Z with timezone abbreviation.</p>
<p>You can also use %t, for a tab and %n for a new line. Combining these together you can produce something quite useful. The following:</p>
<p><code>date '+The Current Time:%nYear: %Y%nMonth: %m%nWeek: %V%nDay: %A (%d of the month, %j of the year)%nHour: %H%nMinute: %M%nSecond: %S'</code></p>
<p>Will produce:</p>
<p><code>The Current Time:<br />
Year: 2010<br />
Month: 01<br />
Week: 04<br />
Day: Sunday (31 of the month, 031 of the year)<br />
Hour: 21<br />
Minute: 13<br />
Second: 59<br />
</code></p>
<p>Very interesting if you want to use it in GeekTool or a script. You can mix and match any of the options to produce what you want. Note that the more options you use the long it can take to work out. I have a feeling your Mac works everything out from the initial date (the time is stored in seconds so the original t value = 0), so the more options you have the longer it will take to run.</p>
<h3>Highlight the Current Date In GeekTool</h3>
<p>You can use the date function to run with the cal function to highlight the current date in GeekTool (even in Terminal). I didn&#8217;t make this code I found it <a href="http://www.macosxhints.com/article.php?story=20091014220449591">here</a>. You can play around with the code to produce different results. You can change the colour with the colour codes, these can be found at the bottom of the page <a href="http://www.termsys.demon.co.uk/vtansi.htm">here</a>.</p>
<p><code>cal_head=`cal | head -1`; cal_tail=`cal | tail -7`; today=`date "+%e"`; echo "$cal_head"; echo -en "${cal_tail/${today}/\033[1;32m${today}\033[0m}";</code></p>
<h3>Conclusion</h3>
<p>The date function is very versatile can be used to give a lot of information. Its good for displaying information and working out factors based on the current time. If you have any tips or tricks please leave a comment below.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/01/working-with-the-date-function-in-terminal.html">Working With The Date Function In Terminal</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/01/working-with-the-calendar-function-in-terminal.html' rel='bookmark' title='Permanent Link: Working With The Calendar Function In Terminal'>Working With The Calendar Function In Terminal</a></li>
<li><a href='http://www.mactricksandtips.com/2009/06/back-date-a-file-using-terminal.html' rel='bookmark' title='Permanent Link: Back Date A File Using Terminal'>Back Date A File Using Terminal</a></li>
<li><a href='http://www.mactricksandtips.com/2008/03/inserting-the-date-time.html' rel='bookmark' title='Permanent Link: Inserting The Date &amp; Time'>Inserting The Date &amp; Time</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Working With The Calendar Function In Terminal</title>
		<link>http://www.mactricksandtips.com/2010/01/working-with-the-calendar-function-in-terminal.html</link>
		<comments>http://www.mactricksandtips.com/2010/01/working-with-the-calendar-function-in-terminal.html#comments</comments>
		<pubDate>Sat, 30 Jan 2010 20:42:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=1647</guid>
		<description><![CDATA[Today and tomorrows post will be a two part mini-series on the date and calendar function within Terminal on your Mac. If you are ever into scripting or working with GeekTool (I have an old post about GeekTool here) it may be very useful to learn how to work with the calendar function in various scripts or what ever you decide to use it with. The calendar function is very useful for producing graphical representations (in text) of any month of any year. Tomorrows post will feature the date function which complements the calendar function nicely. The commands talked about in post can be found (along with more commands) in a variety of books such as Mac OS X Toolbox. Any basic Unix book will feature these basic commands.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/01/working-with-the-calendar-function-in-terminal.html">Working With The Calendar Function In Terminal</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/01/working-with-the-date-function-in-terminal.html' rel='bookmark' title='Permanent Link: Working With The Date Function In Terminal'>Working With The Date Function In Terminal</a></li>
<li><a href='http://www.mactricksandtips.com/2008/01/working-with-widgets.html' rel='bookmark' title='Permanent Link: Working With Widgets'>Working With Widgets</a></li>
<li><a href='http://www.mactricksandtips.com/2008/03/working-out-time-zones-in-ical.html' rel='bookmark' title='Permanent Link: Working Out Time Zones In iCal'>Working Out Time Zones In iCal</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>Today and tomorrows post will be a two part mini-series on the date and calendar function within Terminal on your Mac. If you are ever into scripting or working with <a href="http://projects.tynsoe.org/en/geektool/" target="_blank">GeekTool</a> (I have an old post about <a href="http://www.mactricksandtips.com/2008/10/small-list-of-geektool-commands.html">GeekTool here</a>) it may be very useful to learn how to work with the calendar function in various scripts or what ever you decide to use it with. The calendar function is very useful for producing graphical representations (in text) of any month of any year. Tomorrows post will feature the date function which complements the calendar function nicely. The commands talked about in post can be found (along with more commands) in a variety of books such as <a href="http://www.amazon.com/gp/product/0470478365?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0470478365">Mac OS X Toolbox</a>. Any basic Unix book will feature these basic commands.</p>
<p>To start open Terminal found in Applications &gt; Utilities and type <code>cal</code> (then hit enter) into the command line. Your Terminal will produce something similar to the following.</p>
<pre><code>    January 2010
Su Mo Tu We Th Fr Sa
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
</code></pre>
<p>A nice representation of the current month. This is very useful for graphical representations. You can also use <code>ncal</code>. Its a variation of cal, but produces a different output. Some of the commands either use cal, or ncal.</p>
<pre><code>    January 2010
Mo     4 11 18 25
Tu     5 12 19 26
We     6 13 20 27
Th     7 14 21 28
Fr  1  8 15 22 29
Sa  2  9 16 23 30
Su  3 10 17 24 31</code></pre>
<p>Notice with the ncal output its more square a regular. It does however read in a different direction which can make it slightly more difficult to look and glance at. However ncal does bring with it a couple more features which will be discussed later.</p>
<p>To change the month shown simply type:</p>
<p><code>cal -m apr</code></p>
<p>and the month of the current year will be displayed. The month format is the 3 letter short version; jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec. You can then combine this with a year, anything from 0AD to 9999AD. Minus month and years in the 10th millennium will not compute. For example</p>
<p><code>cal apr 2015</code></p>
<p>This will produce a calendar for April in the month 2015. Notice you don&#8217;t have to append the &#8220;-m&#8221; modifying option. This is so the function can tell when you are imputing a month and not confuse itself over a year with three letters. Note, if you enter the following:</p>
<p><code> cal 2015</code></p>
<p>or</p>
<p><code>cal -m apr -y 2010</code></p>
<p>It will list every day in that year regardless of the -m option. The same works with ncal.</p>
<p>There are a couple of options which can be added to the cal options (other than a specific date) to calculate which week or day in the year you are on. For example you can list each day sequentially in the year, in the calendar format. For example:</p>
<p><code>cal -j apr 2010</code></p>
<p>This produces:</p>
<pre><code>        April 2010
 Su  Mo  Tu  We  Th  Fr  Sa
                 91  92  93
 94  95  96  97  98  99 100
101 102 103 104 105 106 107
108 109 110 111 112 113 114
115 116 117 118 119 120</code></pre>
<p>You can easily tell how many days have ran in April during 2010. The -j options can be appended to any date. This can be quite confusing to which actual day represents which number in the calendar. As a result I run this code to show both dates at the same time.</p>
<pre><code>        April 2010
 Su  Mo  Tu  We  Th  Fr  Sa
                 91  92  93
 94  95  96  97  98  99 100
101 102 103 104 105 106 107
108 109 110 111 112 113 114
115 116 117 118 119 120

     April 2010
Su Mo Tu We Th Fr Sa
             1  2  3
 4  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30
</code></pre>
<p>Here it is clear that April the 14th is the 104th day in the year. In the next post I will show you how you can pick the day number out more easily.</p>
<p>The final option is to show how many weeks have passed in the year. This can only be done with ncal and is used with the -w option.</p>
<p><code>ncal -w</code></p>
<pre><code>    January 2010
Mo     4 11 18 25
Tu     5 12 19 26
We     6 13 20 27
Th     7 14 21 28
Fr  1  8 15 22 29
Sa  2  9 16 23 30
Su  3 10 17 24 31
   53  1  2  3  4
</code></pre>
<p>Note the week number at the bottom of the calendar. This option can be combined with the day number option and used for any month within any year.</p>
<p>Overall this cal options is useful. You can produce a whole variety of calendars in a graphical format. Tomorrow I will show you the date function for showing date and times and using the option to highlight specific dates. If you want to learn more about Terminal, either look through <a href="http://www.mactricksandtips.com/category/terminal/">this category</a> on my site, search my site, or have a look at the many books on <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2Fs%3Fie%3DUTF8%26x%3D0%26ref_%3Dnb%255Fsb%255Fnoss%26y%3D0%26field-keywords%3Dmac%2520unix%26url%3Dsearch-alias%253Dstripbooks&amp;tag=mact06-20&amp;linkCode=ur2&amp;camp=1789&amp;creative=390957">Amazon</a>.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2010/01/working-with-the-calendar-function-in-terminal.html">Working With The Calendar Function In Terminal</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/01/working-with-the-date-function-in-terminal.html' rel='bookmark' title='Permanent Link: Working With The Date Function In Terminal'>Working With The Date Function In Terminal</a></li>
<li><a href='http://www.mactricksandtips.com/2008/01/working-with-widgets.html' rel='bookmark' title='Permanent Link: Working With Widgets'>Working With Widgets</a></li>
<li><a href='http://www.mactricksandtips.com/2008/03/working-out-time-zones-in-ical.html' rel='bookmark' title='Permanent Link: Working Out Time Zones In iCal'>Working Out Time Zones In iCal</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 1.309 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-10 00:20:21 -->
<!-- Compression = gzip -->
