Editing the Command Line

team bbl


Several command-line features assist you with entering commands. For instance, wildcards are available, the same wildcards that you can use with Windows. The asterisk (*) can be substituted for a string of characters and a question mark (?) can be substituted for a single character. Thus, the following command lists all filenames that include var and end with a single character:

 ls *var? xvar1 Study_varA 

File and directory names are completed for you when you press the Tab key. As soon as you have typed enough of the name so that it refers to only one file, press the Tab and the remainder of the filename is filled in on the command line.

The shell stores a history of the commands you enter. You can see it by typing history, which lists the commands, adding a line number at the start of each line.

You can repeat commands using commands that begin with an exclamation point:

  • !! Repeats the last command entered.

  • !string Type an exclamation point, followed by one or more letters that begin a command. The last command that begins with the letters is repeated. For instance, if you type !c, the last command that begins with c is repeated.

  • !n Type the !, followed by a line number. The command shown on that line number in the history list is repeated. For instance, if you type !6, the command on line six of the history is repeated.

You can also repeat a command using the up-arrow key. Each time you press <up arrow>, the previous command displays. Continue to press <up arrow> until you reach the command you want to repeat.

You can edit the previous command and reenter it using ^old^new. The following command will replace string1 with string2 in the first command that just executed:

 srot test.txt ^ro^or 

As shown, you accidentally typed srot, when you meant to type sort. The second line tells the shell to re-enter the command, changing ro to or.

    team bbl



    Spring Into Linux
    Spring Into Linux
    ISBN: 0131853546
    EAN: 2147483647
    Year: 2005
    Pages: 362
    Authors: Janet Valade

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net