| STEP-BY-STEP LINKAGE PROGRAMS GUIDE FOR HUMGEN USERS | |||||||
| LINKAGE HOME | FORMATTING PRIMARY DATA | UNIX EDITING TIPS | ERROR CHECKING | FINAL DATA FORMATTING | PARAMETER FILE PREPARATION | LINKAGE PROGRAMS | RELATED LINKS |
| USEFUL UNIX COMMANDS | |||||
|---|---|---|---|---|---|
| man | emacs | cut | sort | grep | cat |
Man pages for Unix commands
On Unix systems, most Unix commands are associated with "man" pages, which describe how to use the command. To read the man page for a command, type at your prompt: man commandFor example, to get the man page for the 'cut' command, type:
man cut The machine will respond that it is formatting the page, then it will appear in the window.
CUT columns
You cannot cut columns in emacs. Emacs will only allow you to select rows, not columns. Here are instructions on cutting the columns from your data tables you really need, and putting them into a new file.EXTRA CHARACTERS OR FIELDS IN THE FILEIf your genotyper files include a few characters before the family name, you can eliminate those columns before processing with gtyper2.pl by using the cut command. For example, if you have a file with three characters preceding the family name, at the user prompt type:cut -c4-55 genotyper-file-name > cut-file-name
This takes characters 4 through 55 and puts them into the file 'cut-file-name'. (The header of the genotyper file is also cut, but that does not matter because the pattern matched to disregard the header is 'Dye' which is located later in the line.)
To see how many characters are needed in a cut command, copy the length of the line you will need, then type at the prompt: wc -c (and a carriage return). Then in the next line, paste in the copied length and end with another carriage return. On the next (blank) line, press ctrl-d (an escape). The number of characters you pasted in will be returned.
To cut fields of variable width, use -f and -d to denote the separator (default is tab). For example, to cut fields 1 through 5 that are separated by spaces, from file filename:
cut -d" " -f1,2,3,4,5 filename > filename2 also:
cut -f1,3 file > newfile for a tab-delimited file, will put fields 1 & 3 into newfile
Using the SORT command
You may want to sort lines in large files for inspection. The sort command has several useful options. In this example:sort -n -k 2 filename > newfile the sorted lines are put into the file newfile, and:
-n option means sort integers 'correctly' -k option denotes which field in filename to use as key for the sort (here key is field 2) Other useful options:
-u option asks for unique lines only -r option reverses the order for the sorting
Grep can allow you to find our if your file contains a given string of characters. In this example:
grep -in string filename
option -i means don't consider cases of string option -n means report the line number in the file Grep will return the lines that include the string. Grep does many other things; see the grep manual
Using CAT for concatenating files
The cat command will concatenate files. One use is for adding the gtyper2.pl '.name' file to the newprep error ouput, which does not list marker names. In this example:
cat file1 file2 > file3 the contents of file 1 will appear before the contents of file2 in the newfile file3. Note: If file1 does not have a final return, then file2 contents start on the last line with file1 information.
Emacs text editor
Emacs is the best Unix text editor on our system. To invoke emacs from a terminal windown at the Sun Workstation console, type at your prompt:
emacs filename & if you want the file to appear in its own X window (with pull-down menus).
Or, to start emacs within the terminal window (i.e. "windowless"), type:
emacs -nw filename In this case, you will need to learn to use the keystroke commands below; (the mouse will not work). This windowless mode will work from a telnet or remote login window.
If you are not in the same directory as the file, give emacs the path/filename.
Emacs can be complicated. You may learn more about it through the emacs tutorial (under emacs' help menu).
EMACS KEYSTROKES
Emacs windowless commands also work in the X window version. You can move around in the file using the arrow keys. Here are some other basic keystrokes:Save file: C-x C-s
This reads "control x control s" which means you hold down the control key while also pressing the x key, then hold down the control key while pressing the s key. Save file under another name: C-x C-w
then in the minibuffer that appears give the file a new name. After you press the return key, the minibuffer disappears. Open file: C-x C-f
then give the file name in the minibuffer that appears Cut selected text:C-w
Paste text:C-y
Exit or Quit emacs: C-x C-c
Meta-x (M-x) = command-x on most keyboards. M-x gives you the minibuffer through which you give editing commands, for example:
query-replace queries you for both strings, then searches and high-lights each occurrence of the string. (You indicate to accept that replacement by pressing the space bar, or pass over that replacement by pressing the backspace key). replace-regex is for replacing a regular expression. Here you may use a string and/or or use special characters for the pattern matching. For regular-expression pattern matching:
first of line is the character: ^ end of line is the character: $ Setting mark:
C-@ (control shift 2) sets the first mark The second mark is set by wherever the cursor is next placed. C-y (control y) keystroke cuts the marked text C-w (control w) cuts M-w (Meta w) copies C-y (control y) pastes Keystroke for searching:
C-s (control-s), then start typing the string for matching. Emacs will continue to find the next occurrence for each character added as typed... Note: Use 'esc' key to get out of search and keep cursor where it is... Carriage return: C-q C-j (using control-q first lets it know a control character follows)
Keystrokes for tab: C-q C-i
Last updated Feb. 4, 2001