Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

Wednesday, November 16, 2011

Book: Wicked Cool Shell Scripts


Wicked Cool Shell Scripts from No Starch Press looks like it has some handy shell tools for improving productivity, like

An interactive spell-checker
Fixing grep
Downloading Files via FTP
Extracting URLS from a web page
Defining Words Online

Sunday, November 6, 2011

The Unix shell in Macs


After working through Practical Computing for Biologist, I've been turned on to using the Linux shell on my MacBook. A immediately useful feature is being able to run a while script in R without having to open the file.

A short and helpful book for learning more about the shell is Learning Unix for Mac OS X, 2nd Edition from O'Reilly. This was published in 2002 and and is superseded by more recent editions on Tiger and Leopard, but for beginners and dabblers I'm guessing this older (and cheaper) edition is probably just fine (Isn't one of the reasons to use Linux is that it doesn't change much?).

Friday, October 28, 2011

Accessing the Mac Shell through "Terminal"


Terminal is the program that allows you on a Mac to access the shell. Just do a search for "Terminal" and it will come up.

The shell can be used to move, copy, and rename files using typed commands - just as you can with a mouse - and is the entry point for more advanced file manipulation and programming in languages such as Python.

Thursday, October 27, 2011

What does "/usr" mean?

"/usr" stands for "Unix system resource" and is where the programs for many shell commands are stored. It should not be confused with "/User".

awk and sed

Two programs that are suppossed to be great for processing text are awk and sed. According to Haddock and Dunn's Practical Computing For Biologists (2010), the are similar to other general expression environments like the shell function grep, but they "are like programming languages" and provide "even more opportunities to perform complex tasks" (page 78).

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