Replacing and saving time with misspelled commands

How many times do we make a mistake by typing some command in the terminal? ... I don't know about you, but I have a bad habit of making mistakes several times, either because I type in the terminal and at the same time I am attending to the person next to me, or because it is simply such a long line that I am wrong.

The problem with all this is to retype the line, or in any case to press the arriba keyboard, scroll to the mistake we made, fix it and then press [Enter], whatever it may be, it can be a little annoyance 🙂

Well, I will teach you now how to correct any error that you have made when you inserted the previous command, but without even having to type or display that previous command in terminal again 😀

Sounds like magic yes ... fix a misspelled command without ever seeing or typing it again? ... well yes 🙂

For example, I show you the trick without much complication. To access the / var / log / folder in a terminal it would be: cd / var / log or not? well let's open a terminal and misspell that line, let's say:

cd /var/lgo/

As you can see, I changed log to something, which means that I wrote one letter instead of another, that is, a very common mistake 😀

This obviously won't work, it will tell you that the / var / lgo / directory doesn't exist, which is true. Now in that same terminal write:

^lgo^log^

And press [enter], you will see how they magically accessed the correct directory LOL !!

What does this mean? 0_oU ...

Simple, we put first what is the error (lgo) and then we put why we want to change it (log), this entire line starts with a character ^ and ends the same with the same character, in turn this character is the one who divides the error from what is correct to put.

Simply put, they put a ^, then they put where they went wrong, they put another ^ which would be the division, then they put what they wanted to be correct and end up with another ^. Simple right? 😀

I know that some will still prefer to press [Up] and correct the error in the command line, others may use this tip, the truth is that everyone will surely find it interesting ... and if not, well, at less they already learned a new trick 😀

regards


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   hexborg said

    Very good!! A very useful trick that I never remember to use. LOL!! Another one that I like is pressing Alt +. to retrieve the last parameter of the previous command. If you give it several times it goes through the previous commands.

    I love the terminal. 🙂

  2.   rogertux said

    I did not know him. Whenever I made a mistake, I spent half an hour fixing the previous command. Now I will know what to do 🙂

  3.   Warp said

    Well, I have Arch, and it fixes the error by itself…. I just got blown away, hehehe

  4.   Leper_Ivan said

    I did not know this tip, thank you ..

  5.   Moderate versionitis said

    Yes, I keep staying with hehe .. because generally I don't remember where I went wrong .. hehehe ..
    Interesting about the Arch Terminal autocorrect.

  6.   Scalibur said

    Good!..

    Great! .. ..it is like a glove! .. ..interesting tip, and of immediate application .. 😉

    PS: I love to use the console, my first experience in linux was a bare Debian installation, only console 😛 ..

  7.   helena_ryuu said

    as always very interesting your tips kzkg ^ gaara (your nick is not weird do not match yourself xD)

  8.   Hugo said

    Funny trick.

    Another peculiar way to do it (useful for long commands) is through the fc (fix command) command, which launches the default editor (usually vim or nano, although it can be changed by putting something like "export EDITOR = mcedit" in the .bashrc) With a line that contains precisely the command that we just typed, when we edit it, save the changes and exit the editor, our interpreter executes the command.

    1.    hexborg said

      Very good trick. I did not know him.

    2.    msx said

      Ditto, good data!
      The same @KZ, I did not know the trick, hyper comfortable!

  9.   sieg84 said

    interesting data.

  10.   Blaire pascal said

    Oh, I rarely use the terminal, but it's true that many of us have experienced this many times, and it's really annoying so far. Excellent tip.

  11.   Nonamed said

    interesting, thank you very much, I hope to remember when I need it 😀

  12.   xykyz said

    Well, this has many uses: O

  13.   semproms said

    In the KDE terminal it won't let me enter the "^" character on the keyboard, does anyone know how to solve it? And thanks for the trick, it's always interesting to meet new ones.

    A greeting.

  14.   MystoG @ N said

    Ñoooooooooo man !!!! Where were you with that command when I needed you ???? Look at the "little" command that I had to use repeatedly a few days ago, to be able to migrate mailboxes from one server to another

    imapsync –buffersize 8192000 –noauthmd5 –nosyncacls –subscribe –syncinternaldates –ssl1 –ssl2 –host1 10.30.150.3 –user1 agustin.castillo –password1 pass *** 123 –host2 10.30.150.7 –user2 agustin.castillo –password2 pass *** 123

    Do you know how many times I was wrong when changing user ???

    1.    KZKG ^ Gaara said

      HAHAHA!!! 😀 😀
      These are things that I discover almost at random ... LOL !!

  15.   Joaquin said

    Very good tip!
    The things one learns.

  16.   anonymous said

    Interesting, but I find it complex ... my method is using the command "$ history | grep -i command-to-search-in-command-history".
    It gives me a list of commands executed with their index number, then to execute one for example I put! 242 and enter.

    Example:
    # history | grep -i cat
    206 2013-09-16 01:02:49 cat / etc / issue
    214 2013-09-16 00:59:04 cat /etc/slim.conf
    223 2013-09-16 01:07:56 cat /etc/pam.d/slim
    242 2013-09-16 03:26:37 cat .xinitrc
    250 2013-09-17 02:28:53 cat / proc / cmdline

    #! 242

    Maybe you already knew, for me it is very practical.
    Thanks for these tips that you publish, every day I love my urvxt more.

  17.   daniel2ac said

    I like the ~ / .inputrc trick better

    "\ E [A": history-search-backward
    "\ E [B": history-search-forward

    It's very fast and makes you get used to it XD I can't use bash anymore without this trick hahaha