410 2.1 Command Line
Bi 410/510: Command Line Interface Links
1 Overview
1.1 covered in Ch 4 and 5 of PCFB
1.2 no project
1.3 suggested exercises to help you get familiar with commands
2 History history.p…
3 File Hierarchy
3.1 in Unix terminology, a folder is called a directory
3.2 directories can contain files of any type or subdirectories
3.3 the top level folder is called the root directory
3.4 download, unpack a file named greeks.tgz [open greeks in Finder]
a folder with seven subfolders and a text file
use it to practice shell commands
4 Paths
4.1 a string that specifies a set of nested folders is a path
4.2 examples
greeks/delta/diogenes.txt
greeks/alpha/images/photos.tgz
4.3 the / character between folder names is the separator character
Windows uses a backslash (\)
Linux and Mac OS X are derived from Unix, use the forward slash (/)
5 Terminal Window
5.1 shell [open Terminal, go to documents]
prompt
enter command, hit return
example: ls (“list the contents of a folder”)
5.2 shell commands
first word is name of program to run
lots are built in (ls, cd, wc, etc)
others are names of applications (python, etc)
5.3 cd / ls
first commands to learn: cd (“change directory”) and ls (“list directory”) [dir in Windows]
all commands are run from a specific folder, called the “current directory”
** locate where you saved the greeks folder, see if you can use cd commands to navigate to that folder
** type the ls command to show you the contents of the folder
5.4 arguments
additional words typed on command line are often file names or other arguments
examples:
ls greeks
ls greeks/delta greeks/epsilon
these words are passed to the program as an “argument vector”
5.5 options
by convention, arguments that start with a dash are options
example: ls -l, ls -a 5 Terminal Window
5.1 shell [open Terminal, go to documents]
prompt
enter command, hit return
example: ls (“list the contents of a folder”)
5.2 shell commands
first word is name of program to run
lots are built in (ls, cd, wc, etc)
others are names of applications (python, etc)
5.3 cd / ls
first commands to learn: cd (“change directory”) and ls (“list directory”) [dir in Windows]
all commands are run from a specific folder, called the “current directory”
**Bi locate 410/510: where you savedCommand the greeks folder, Line see Interface if you can use cd commands to navigate to that folder Links
** type the ls command to show you the contents of the folder
5.4 arguments
additional words typed on command line are often file names or other arguments
examples:
ls greeks
ls greeks/delta greeks/epsilon
these words are passed to the program as an “argument vector”
5.5 options
by convention, arguments that start with a dash are options
example: ls -l, ls -a
6 Navigation
6.1 working directory (where commands are executed)
6.2 pwd (print working directory)
6.3 special arguments: . and ..
7 Printing the Contents of a File
7.1 cat
7.2 more
8 Searching
8.1 grep
8.2 egrep
9 Miscellaneous
9.1 echo
9.2 wc (word count)
10 Redirection
10.1 Use > to save output to a file
echo “hello, world” echo “hello, world” > hello.txt
11 Pipes
11.1 the “pipe” symbol connect the output of one command as the input to another command
11.2 example: how many reference entries are at the start of the Genbank file?
[sasquatch:downloads] ➤ grep REF NC_000913.prefix.txt ... REFERENCE 15 (bases 1 to 4639675) COMMENT PROVISIONAL REFSEQ: This record has not yet been subject to final RKKIRNEQRFASLDELKAQIARDELTAREFFGLTKPA" ...
[sasquatch:downloads] ➤ egrep '^REF' NC_000913.prefix.txt REFERENCE 1 (bases 1 to 4639675) REFERENCE 2 (bases 1 to 4639675) REFERENCE 3 (bases 1 to 4639675) ...
[sasquatch:downloads] ➤ egrep '^REF' NC_000913.prefix.txt | wc 15 90 540