Thursday, October 27, 2011

Rocking the Shell: Basic Mac OS X Shell commands

I'm using Haddock and Dunn's excellent Practical Computing For Biologists to learn how to use the "shell" to access files on my Mac.

Here are the basic shell commands they discuss in Chapter 4. I'm only annotating those that don't have an analog in R, or that I don't remember from using the DOS prompt on my family's 386 desktop back in the '90s!

Directory/file information:
ls
ls -a
ls -l
ls -l -a
pwd

Navigation:
cd ..
exit

View files
cat
less -- view text files
man -- view "manuals"/help files

Directory/file manipulation
mkdir
rmdir
cp -- copying files
mv -- moving files
rm

Misc.
alias -- in your bash_profile; creates shortcuts
chmod -- "change mode"
cat .bash_profile -- print the contents of the file that set your shell settings
echo $PATH -- print the locations where the shell looks for programs to be located
which -- shows the location of a program or command is stored
curl --
"see URL"; download web data
wc
file -- character, word, and line count for a file
history

history | grep "search" -- "pipe" your command history over to grep and have grep locate commands with the term "search" in them.


Curl
-0 -- output operator


Modifiers to grep
-i -- ignore case of search term
-v -- "not" or "except"
-c
-E
-l
-n
-h

No comments:

Post a Comment