|
|
| | | | |
| | * '''Note:''' The '''Tab''' key also works with '''ls -F''', but we’ll skip over that for now. | | * '''Note:''' The '''Tab''' key also works with '''ls -F''', but we’ll skip over that for now. |
| | + | |
| | + | === Basic File Commands === |
| | + | |
| | + | There are ''lots'' of file commands, but for introductory purposes we’ll present the two basic ones which you have probably used in a non-command way already. |
| | + | |
| | + | ==== Copy File: cp ==== |
| | + | |
| | + | To copy a file from one place to another, use this command: |
| | + | cp <file to copy> <destination of copy> |
| | + | You have probably copied files before, such as from a laptop to a flash drive. In mouse/touch environments, this operation is typically a drag-and-drop—you hold down a mouse or trackpad on the icon of the file to copy, then drag it to the icon of the flash drive destination. Usually, the mouse cursor changes to show that you are about to perform a file copy (a common sign is the appearance of a “+”). In addition, there is a safety net that warns you if you are about to copy a file into a destination where a file of the same name already exists. |
| | + | |
| | + | In Windows, you can also click on an icon to select the file, choose ''Copy'' from a menu, then navigate to the destination and finally click ''Paste''. Note the similarities in the pattern, regardless of the specific mechanism: indicate the file to copy, then indicate where the copy should go. If you think of the '''cp''' command in this way, that may make the learning go more smoothly. |
| | + | |
| | + | In the end, though, there ''are'' some differences to note: |
| | + | * Already mentioned is the way we are used to receiving warnings if we are about to copy over a file that already exists. The command line does not do this by default. If you would like to play it safer and be given that warning, ad a '''-i''' to the command, separated by spaces: |
| | + | cp -i <file to copy> <destination of copy> |
| | + | :The “i” stands for “interactive,” which may make it easier to remember. |
| | + | * Don’t forget, you can use various commands in any order. You can use '''ls''' or '''cd''' at any time to get a handle on what files are around and where. After performing a copy, you can use those commands again to make sure that the file really did get copied. Part of getting used to the command line is the ability to string individual commands together in a meaningful way. |
| | + | * We are accustomed to copying files to a folder or directory, and indeed '''cp''' can work that way. However, it does have one other option which might not immediately be obvious in other user interface styles: you can copy a file ''and'' give the copy a new name in a single command. For example, if you want to copy a file called ''genetic-code.sed'' from the ''~dondi/xmlpipedb/data'' folder into your home directory but want to rename the copy as ''gc.sed'', you can do this in one line: |
| | + | cp ~dondi/xmlpipedb/data/genetic-code.sed ~/gc.sed |
| | + | :(remember the '''~''' shortcut for home directories above) |
| | + | * Finally, the '''..''' shorthand for the folder “above” the current one still holds here. That is another pattern to realize about the command line: the “vocabulary” of shorthand and symbols typically apply across whole families of commands. Thus, once you learn how to use one command well, chances are that you are a leg up in learning other related ones. |
| | + | |
| | + | ==== Move File: mv ==== |
| | + | |
| | + | Sometimes you don’t want to copy a file, but just move an existing one from one folder to another. The command for this is '''mv''' (“'''m'''o'''v'''e”), and its structure is very much like that of '''cp''': |
| | + | mv <file to move> <new location of the file> |
| | + | Note again the ''conceptual'' similarity between this command and what you may be used to (i.e., drag-and-drop of a file icon from one place to another; selecting a file, choosing ''Cut'' from a menu, then choosing ''Paste'' at the file’s new location): all commands indicate the file to move, then the destination of the file. It’s just ''how'' you express this that differs for each mechanism. |
| | + | |
| | + | Most of the bullet points for '''cp''' also apply to '''mv''', including the '''-i''' safety net option (remember what we said about having that shared “vocabulary?”). Plus, '''mv''' has one last twist of its own... |
| | + | |
| | + | ==== Rename File: mv (!) ==== |
| | + | |
| | + | Yes, the command to ''rename'' a file is also '''mv'''. That’s because the command line does not distinguish between a move and a rename—renaming a file is simply “moving” it from a file of one name to a file of another. Thus, renaming a file is: |
| | + | mv <old name of file> <new name of file> |
| | + | Note how this reflects a certain minimalism or non-redundancy in how commands are defined—instead of creating a whole new command for some operation, if another command effectively does the same thing, then the choice is to use that instead of defining another one. |
| | | | |
| | == Processing Text == | | == Processing Text == |
|
|
| | ==== Location of Sample Files ==== | | ==== Location of Sample Files ==== |
| | | | |
Unexpected non-MediaWiki exception encountered, of type "Error"
Error: Call to undefined function each() in /apps/xmlpipedb/biodb/fall2013/includes/diff/DairikiDiff.php:374
Stack trace:
#0 /apps/xmlpipedb/biodb/fall2013/includes/diff/DairikiDiff.php(480): _DiffEngine->_diag()
#1 /apps/xmlpipedb/biodb/fall2013/includes/diff/DairikiDiff.php(291): _DiffEngine->_compareseq()
#2 /apps/xmlpipedb/biodb/fall2013/includes/diff/DairikiDiff.php(175): _DiffEngine->diff_local()
#3 /apps/xmlpipedb/biodb/fall2013/includes/diff/DairikiDiff.php(653): _DiffEngine->diff()
#4 /apps/xmlpipedb/biodb/fall2013/includes/diff/DairikiDiff.php(820): Diff->__construct()
#5 /apps/xmlpipedb/biodb/fall2013/includes/diff/DairikiDiff.php(1240): MappedDiff->__construct()
#6 /apps/xmlpipedb/biodb/fall2013/includes/diff/DairikiDiff.php(1458): WordLevelDiff->__construct()
#7 /apps/xmlpipedb/biodb/fall2013/includes/diff/DairikiDiff.php(952): TableDiffFormatter->_changed()
#8 /apps/xmlpipedb/biodb/fall2013/includes/diff/DairikiDiff.php(895): DiffFormatter->_block()
#9 /apps/xmlpipedb/biodb/fall2013/includes/diff/DifferenceEngine.php(765): DiffFormatter->format()
#10 /apps/xmlpipedb/biodb/fall2013/includes/diff/DifferenceEngine.php(655): DifferenceEngine->generateDiffBody()
#11 /apps/xmlpipedb/biodb/fall2013/includes/diff/DifferenceEngine.php(593): DifferenceEngine->getDiffBody()
#12 /apps/xmlpipedb/biodb/fall2013/includes/diff/DifferenceEngine.php(566): DifferenceEngine->getDiff()
#13 /apps/xmlpipedb/biodb/fall2013/includes/diff/DifferenceEngine.php(409): DifferenceEngine->showDiff()
#14 /apps/xmlpipedb/biodb/fall2013/includes/Article.php(725): DifferenceEngine->showDiffPage()
#15 /apps/xmlpipedb/biodb/fall2013/includes/Article.php(478): Article->showDiffPage()
#16 /apps/xmlpipedb/biodb/fall2013/includes/actions/ViewAction.php(37): Article->view()
#17 /apps/xmlpipedb/biodb/fall2013/includes/Wiki.php(427): ViewAction->show()
#18 /apps/xmlpipedb/biodb/fall2013/includes/Wiki.php(304): MediaWiki->performAction()
#19 /apps/xmlpipedb/biodb/fall2013/includes/Wiki.php(536): MediaWiki->performRequest()
#20 /apps/xmlpipedb/biodb/fall2013/includes/Wiki.php(446): MediaWiki->main()
#21 /apps/xmlpipedb/biodb/fall2013/index.php(59): MediaWiki->run()
#22 {main}