Fix: VIM Fix UP and Down Keys Inserting A B C D Character On Remote SSH Session on a Linux or Unix Systems

Posted on in Categories , , last updated February 10, 2015

I am login to a remote server using a ssh client. I am annoyed with the arrow key behavior during insert mode in Vim. As soon as I hit arrow keys, vim display A B C D on screen. How do I fix this problem under Linux, FreeBSD, OpenBSD, NetBSD, Apple OS X or Unix-like operating systems? How can I fix arrow keys that display A B C D on remote shell?

Linux / Unix: sed Command Print Only Matching Lines

Posted on in Categories last updated October 19, 2012

I see many examples and man pages on how to do operations like search-and-replace using sed. But, I want to match a given string or a regular pattern expression and display on the screen. How do I print lines with matching pattern using sed command only under Unix like operating systems?

Bash History: Correct / Repeat The Last Command With a Substitution

Posted on in Categories , , last updated February 23, 2016

I often type the wrong command as follows under Linux bash shell:

rsync -av dir1 [email protected]:/path/to/dir1

OR

cp -av file1*.txt file2*.txt /path/to/dest

I need to correct those command as follows:

rsync -av dir5 [email protected]:/path/to/dir1
cp -av delta1*.txt delta2*.txt /path/to/dest

How do I replace dir1 with dir5 or file with delta and repeat the last command under bash shell?