Difference between revisions of "Command Line Crib Sheet"
From LMU BioDB 2013
(A few more commands.) |
(→Commands, Special Symbols, and Keyboard Shortcuts: A few more commands.) |
||
Line 9: | Line 9: | ||
| forward slash | | forward slash | ||
| Separates successive folders in a '''cd''' command | | Separates successive folders in a '''cd''' command | ||
+ | |- | ||
+ | | '''<''' | ||
+ | | input redirect/less-than sign | ||
+ | | Specifies that the content of a file (to the right of the '''<''') should serve as the input into the command on the left | ||
+ | |- | ||
+ | | '''>''' | ||
+ | | output redirect/greater-than sign | ||
+ | | Specifies that the result of a program (to the left of the '''<''') should be saved into the file on the left | ||
+ | |- | ||
+ | | '''|''' | ||
+ | | pipe | ||
+ | | Connects one command line program to another: the result of the program to the left of the '''|''' becomes the input into the program to the right | ||
|- | |- | ||
| '''~''', '''~username''' | | '''~''', '''~username''' | ||
| tilde | | tilde | ||
| Shortcut for a user’s home folder; when immediately followed by a username (no spaces), this represents ''that'' user’s home folder | | Shortcut for a user’s home folder; when immediately followed by a username (no spaces), this represents ''that'' user’s home folder | ||
+ | |- | ||
+ | | '''cat ''<filename>''''' | ||
+ | | con''cat''enate a file (long story) | ||
+ | | Display the contents of the given file | ||
|- | |- | ||
| '''cd ''<directory or folder>''''' | | '''cd ''<directory or folder>''''' | ||
Line 20: | Line 36: | ||
| '''cp -i ''<file to copy>'' ''<destination of copy>''''' | | '''cp -i ''<file to copy>'' ''<destination of copy>''''' | ||
| copy file | | copy file | ||
− | | Copies the given file to the given destination | + | | Copies the given file to the given destination; the '''-i''' stands for “interactive,” meaning that '''cp''' will ask permission if a file at the destination might get replaced |
|- | |- | ||
| '''Ctrl-C''' | | '''Ctrl-C''' | ||
Line 49: | Line 65: | ||
| list files | | list files | ||
| Display the files in the current directory; adding a '''-F''' to the command (i.e., '''ls -F''') adds a symbol to the file listings indicating their type | | Display the files in the current directory; adding a '''-F''' to the command (i.e., '''ls -F''') adds a symbol to the file listings indicating their type | ||
+ | |- | ||
+ | | '''mv -i ''<file to move or rename>'' ''<new location or name of the file>''''' | ||
+ | | move or rename a file | ||
+ | | Move or rename a file; as with '''cp''', the '''-i''' is an “interactive” mode that asks permission if something might get replaced | ||
|- | |- | ||
| '''pwd''' | | '''pwd''' |
Revision as of 21:14, 15 September 2013
Commands, Special Symbols, and Keyboard Shortcuts
! | exclamation point/bang | Shortcut for repeating a command—!<command number> repeats the command with that number (as listed by the history command); !! repeats the last command |
/ | forward slash | Separates successive folders in a cd command |
< | input redirect/less-than sign | Specifies that the content of a file (to the right of the <) should serve as the input into the command on the left |
> | output redirect/greater-than sign | Specifies that the result of a program (to the left of the <) should be saved into the file on the left |
pipe | becomes the input into the program to the right | |
~, ~username | tilde | Shortcut for a user’s home folder; when immediately followed by a username (no spaces), this represents that user’s home folder |
cat <filename> | concatenate a file (long story) | Display the contents of the given file |
cd <directory or folder> | change directory | Changes the current directory/folder to the one indicated in the command |
cp -i <file to copy> <destination of copy> | copy file | Copies the given file to the given destination; the -i stands for “interactive,” meaning that cp will ask permission if a file at the destination might get replaced |
Ctrl-C | “Panic” key—bail out of the current program and jump back to the command line | |
Ctrl-D | “End input” key—ends a program when using it in “practice” mode (where you type the data that you want it to manipulate) | |
exit | exit | Log out of your command line session. |
history | history | Lists the commands you have typed so far |
left/right arrow keys | Go backward/forward across current command (allowing you to edit it) | |
logout | logout | Log out of your command line session. |
ls | list files | Display the files in the current directory; adding a -F to the command (i.e., ls -F) adds a symbol to the file listings indicating their type |
mv -i <file to move or rename> <new location or name of the file> | move or rename a file | Move or rename a file; as with cp, the -i is an “interactive” mode that asks permission if something might get replaced |
pwd | print working directory | Displays the directory/folder in which you are working; the command prompt also shows this |
Tab key | autocomplete | Lists possible matching choices if there is more than one, or autofills immediately if there is only one match |
up/down arrow keys | Go back and forth through command history |
Search Pattern Symbols (a.k.a. regular expression or regex symbols)
Used by grep, sed, and XMLPipeDB Match to indicate what patterns to find.
. | Single-character wildcard | Matches any character |
* | Zero or more | Matches zero or more of the symbol that precedes it |
^ | Beginning of line | Matches the pattern after it only if it appears at the beginning of a line |
$ | End of line | Matches the pattern before it only if it appears at the end of a line |
+ | One or more | Matches one or more of the symbol that precedes it |
\" | Double-quote character | Matches a double-quote in a line; the extra backslash (\) is needed so that this quote is not confused for indicating the end of the search pattern |
\d | Number 0-9 (i.e., digit) | Matches any single-digit number |
\w | Letter or number (i.e., something that would appear in a word) | Matches any letter or number, but not punctuation, spaces, or other symbols |
sed Search/Replace Directives
To be written.