Aug.29,Good command line usage habits and tips
作者:范范 日期:2010-08-30
If you use the command line frequently, chances are you may have some bad command line habits. IBM's DeveloperWorks site has posted 10 good UNIX usage habit tips, some of them are just pretty handy tricks in general and if you're new to the Mac OS X Terminal, you'll probably learn something since practically all of them work within the Mac OS X command line. Here's one of my personal favorites since it hit home with my command line activities:
* Change the path to unpack something into rather than moving the archive file itself, in this example by using the -C flag with the tar command:
tar xvf -C path/to/unpack newarc.tar.gz
I'm certainly guilty of moving archives around, but that's partially because I like to keep all of them in a central location. But if you're going to just delete the archive anyway, there's no point in moving the archive file around just to unpack it. Save yourself the keystrokes.
Here's the full list of tips in the IBM DeveloperWorks article:
Aug.23,Compare 2 directories contents using diff
作者:范范 日期:2010-08-24
If you want to see the difference between two folders on a Mac, launch the Terminal and read on. Using the command line tool 'diff' you can easily compare the contents of any two directories, here's the command we'll use to achieve this:
diff -rq directory1 directory2 >> differences.txt
This executes the diff command comparing directory1 and directory2 (if you have a folder with a space in the file name, just put it in quotes like so: "folder one"), and then redirects the output of that command to a file named differences.txt. Here's an example and how the actual printout will look:
diff -rq "old music" "new music" >> musicfolders.txt
Aug.12,Repair disk permissions from command line
作者:范范 日期:2010-08-13
You can initiate the same Repair Disk Permissions functionality that is seen in Disk Utility via the Terminal by typing the following command in the Terminal:
diskutil repairPermissions /
This will repair the disk permissions on your Mac's main drive, if you want though you can run it on another disk by specifying it rather than / at the command line. Once the command has been executed you will see a message like:
Started verify/repair permissions on disk0s2 Mac HD
The time it takes to repair the disk permissions depends on various factors, but the command will update as permissions are repaired and will end itself when diskutil is finished. If you have verified disk permissions and you find a bunch of problems, you might want to cross check them with this list from Apple for errors that you can safely ignore.
Jul.24,Using Quick Look from the Command Line
作者:范范 日期:2010-07-25
Sometimes you need to Quick Look a file, but you're in Terminal or iTerm or something. If you're dealing with images, you want to see them before you do anything. But you don't want to use the open command. That's where qlmanage comes in.
qlmanage is a CLI tool that, from the manpage, is a 'Quick Look Server debug and management tool.' It's got more options than described below, but those are for developers debugging QL.
The -p option generates a preview, as if you'd tapped the Space bar in the Finder. The -t option generates thumbnails, like in Coverflow or Info For. Here, then, are typical uses of the tool:
- qlmanage -p '/Users/Name/Music/Player.mp3'
Generates a QL window in Terminal. - qlmanage -t '/Users/Name/Pictures/Image.png'
Generates a window with a thumbnail. - qlmanage -p '/Users/Name/Documents/Nurse.doc' '/Users/Name/Movies/Liters.mpg'
Generates a QL window in Terminal with a page-through option to see both docs.
Mar.3,两则OS X终端命令应用小技巧
作者:范范 日期:2010-03-04
081116,Run.Unix.apps.on.your.Mac
作者:范范 日期:2008-11-17
Brian Jepson
----------
If you’ve ever thought about running Unix programs on your Mac, you might have hesitated because you assumed that meant you were stuck with the command-line interface. But you aren’t.
Go to Leopard’s Applications/Utilities folder and double-click on X11.app. That will ope...







