Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
In bash shell, how can I replace a character under the cursor with another character ?
In the below example , after I typed the following line, I realized that I meant 7018 and not 2018. So I move the cursor to the left and keep it on top of 2 (of 2018) and I want to replace 2 with 7. How can I do that ?
$ echo hello 2018
This question is not about replacing characters in a text file using vi/vim/emacs editors.
A video example (for more clarity)
In the below video, how is this guy changing 2010 to 2011 instantly ? He also changes 2011 to 2012 , ... etc
In bash shell, how can I replace a character under the cursor with another character ?
In the below example , after I typed the following line, I realized that I meant 7018 and not 2018. So I move the cursor to the left and keep it on top of 2 (of 2018) and I want to replace 2 with 7. How can I do that ?
Personally I go to the point just after the character, hit BACKSPACE to delete that character, and then type in my correction.
Meanwhile there is such as thing as insert mode which is natively on, in my terminal. Appears not to be in that video.
this is on macos, and while macos uses (its own version of) bash, it could also be a different shell.
it could be a function of that different shell, or a function of macos' terminal app, or one of the solutions proposed earlier.
Didn't really view that video in great enough detail. It is a good point, ondoho.
Meanwhile the behavior of overwrite is typically controlled by the INSERT key on my keyboard.
My default is that if I migrated back to part of my command and type something, it'll insert the new character, hence my description of what I normally do.
If I hit the INSERT key once, it now changes the mode to be overstrike, or overwrite and I see the exact same behavior from that video.
I've never preferred that mode. It doesn't work on all types of system terminals. But that's also what I meant when I used that term in my last post.
Personally I go to the point just after the character, hit BACKSPACE to delete that character, and then type in my correction.
Yeah, in my experience, this nearly always works ie it's the default 'setting' unless someone has customised the login files and set it to OVERSTRIKE mode instead, but that is rare and easy to fix.
In bash shell, how can I replace a character under the cursor with another character ?
In the below example , after I typed the following line, I realized that I meant 7018 and not 2018. So I move the cursor to the left and keep it on top of 2 (of 2018) and I want to replace 2 with 7. How can I do that ?
$ echo hello 2018
On my console, DEL followed by 7 would do that. Does that not work for you?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.