Search

Top Posts

Comments

  • jc: @echo_host thanks for the updates… here are my questions 1. after you did that, what does it show in system...
  • iphone: Really informative. thanks.
  • RCB: Works great at Six Flags. Never had any moisture get in after drenching rides like Thunder River, Log Flume, etc.
  • TvvitterBug: Nice article! I think the Twitter client landscape has really changed in 2010. New approaches and design...
  • DistortedLoop: I’ve been putting electronics in ziplock bags for years as a quick and dirty water-RESISTANT...

Categories

Recent Posts


Command Line usability basics: Redirection

Mac OS X is so user friendly that many Mac users probably don’t know they’re sitting on top of a powerful Unix base, accessible by the Terminal app. Our feeling is that since the command line is there, you should be able to use it to some extent. In our continued quest to propagate OS X command line knowledge, we bring you some information on the extremely useful redirect utilities. Redirects allow you to take the output of certain commands and create new files or add to existing ones with this data, very useful indeed.

Command Usage
command > newfile Redirects the output of the command to newfile
command >> existingfile Appends the output of the command to the end of existingfile

Examples of redirects in use:

If you wanted to create a text file with data from the ps command, but controlled only for Dashboard related processes running, this is what you would type at the command line:
ps -aux | grep Dashboard > dashboarddata.txt

If you wanted to add at the end of the file we just created, dashboarddata.txt a list of Widgets you have installed, you would type the following:
ls -l /Library/Widgets >> dashboarddata.txt

The uses for redirection are endless and you’ll find that the more time you spend in the command line, the more you’ll want to use redirect for aiding certain tasks.

Posted by: Editor

Share

Save big on Mac Deals from Amazon.com

Comments:

Comments: 4

Comment from anon
Time: March 29, 2007, 9:37 am

thanks, you’re slowly making me less of an idiot in the command line department, but I have to admit I don’t find any practical use for much of this knowledge…

Why would you really use redirects like this in a real world setting?

Pingback from It’s Beta » Blog Archive » Command Line usability basics: Redirection
Time: March 29, 2007, 9:41 am

[...] [link][more] [via: reddit.com: newest submissions | article link] [...]

Comment from Brian Burleigh
Time: April 9, 2007, 11:17 pm

@ anon

g++ file1.cpp file2.cpp -o program.o >> compileinfo.txt

Pingback from Swedegeek’s Blog » Why Selfish Blogs Suck
Time: April 22, 2007, 5:22 pm

[...] It’s a month old now, but I’ve been meaning to write on this post that, from its title, claimed to be a tutorial on Unix-based command line redirection. I use *nix systems on a regular basis, and I actually got suckered into clicking to this article. It was a waste of time. And then I got even annoyed by thinking about things on a deeper level. I hate thinking. [...]

Write a comment






March 29th, 2007