Delete key is printing "^?" instead of deleting - ssh

I am ssh-ing into a server and when I am editing files, the Delete key does not delete; instead it prints "^?"
How can I fix this so that the Delete key actually deletes the character before the cursor?

At the shell:
$ stty erase ^V<delete key>
where ^V is control-V, followed by the key you wish to use as the Delete key. Then, of course, press Enter.

Related

Vscode vim key remapping for append "a" key

I am having a hard time adjusting to vscode vim i want to remap append mode key "a" to key "h" .
what should I type in command <"help plzz">

How to bulk delete hundreds of thousands of keys with special characters in Redis

We have a list of hundreds of thousands of Redis keys containing all sorts of special characters and we would like to bulk delete them. There are some great answers to a similar problem on this question: How to atomically delete keys matching a pattern using Redis
HOWEVER, I can't seem to find an answer for the case where:
We have a large number of keys (hundreds of thousands)
The keys have all manners of special characters like double quotes ("), backslashes (), all sorts of weird Unicode characters, etc.
We are using the windows redis-cli client
Bonus: Ideally we would be able to issue this command as part of a MULTI/EXEC transaction so we can also delete a SET atomically along with the keys.
I would LOVE if we could just do something like the below, but have it handle keys with all of the special characters that give Redis problems:
redis-cli SMEMBERS "myGiganticListOfKeys" | xargs --delim='\n' redis-cli DEL
Unfortunately this just gives the below error:
"C:/Program Files (x86)/Git/bin/xargs.exe": redis-cli: Bad file number
I think this would otherwise work if we didn't have special characters in the keys.
Thanks so much in advance.
Here's how I solved it, this works for zillions of records without stressing redis.
WARNING: PLEASE DO NOT TRY THIS AT HOME UNATTENDED AND MAKE SURE TO WEAR
ALL SAFETY EQUIPMENT NECESSARY FOR THE TASK.
Step 1. Dump all the keys you need from redis to a file, lets call this file YES_WE_CAN.sh
redis-cli KEYS "StartsWith*" > YES_WE_CAN.sh
Step 2: Open the file YES_WE_CAN.sh with vi or vim and press : character, then type the following to replace the special character ':
:%s/'/'"'"'/g
This will replace all ' characters with '"'"' escape sequence. (Trust me, this works, keep going!)
Step 3: Prepend to each string redis-cli DEL (dont forget the space at the end):
:%s/^/redis-cli DEL /g
Step 4: Append at the end of each line the ' character:
:%s/$/'/g
Step 5: Save the file and quit using :wq
Step 6: Change the file YES_WE_CAN.sh to executable mode:
chmod +x YES_WE_CAN.sh
Step 7: Run the file:
./YES_WE_CAN.sh
Enjoy your coffee while the script deletes the millions of keys you requested.
You should try creating an application using a more robust client.
See the client list.
The redis-cli is a very basic command-line utility intended just to hack/play with Redis.
I agree with you that the best will be to re-design your key/value store.
Consider using a tagging mechanism if you need to invalidate multiple keys: Use a hash to group keys by tag when the keys are added, and then invalidate the entire tag removing all the keys in the hash.

shortcut key to get the previous command in ksh

Shortcut key to get the previous command in ksh
What is the shorcut key to get the previous command that was used in ksh?
I have tried using the history command but that is not my requirement.
I want to know the shortcut key.
If you first set the editor mode to "vi";
set -o vi
Then you can access history by entering command mode (press Esc key), and using either the up arrow or the 'k' key.
From there, vi editing syntax works - e.g. to edit the line enter insert mode ('i') etc. Hitting return will re-execute the command, and Ctrl-C will cancel.

Create a file with content through ssh without a text editor

I am aware that it is possible to create a file in ssh through the "touch" command then editing it using text editors such as vi or pico to edit them and add content.
I was wondering if it was possible to create a file and add it's contents in one command line?
Something like:
[create file command] [filename.txt] ["this is the contents of filename.txt"]
The reason I'm asking if this was possible is because I have an ssh client in Go where a session only accepts one call to run and I plan to use this for an app that is automated with no user inputs so I want to avoid using text editors.
Here's one solution:
ssh [user#]hostname 'echo "this is the contents of filename.txt" > <path/filename>'
The echo with ">" overwrites an existing file, or creates a new file if it doesn't exist.
Replace ">" with ">>" to append the text to an existing file.
Cheers

How to keep ssh-keygen from using my login and computer name in the public key?

I ran ssh-keygen on OS X and when I displayed the public key generated, I saw that my login and machine name appears in the last part of the key. Is there any way to have it use a different value or not use it at all?
From the manpage ‘ssh-keygen(1)’:
For RSA1 keys, there is also a comment field in the key file that is only for
convenience to the user to help identify the key. The comment can tell what the
key is for, or whatever is useful. The comment is initialized to “user#host”
when the key is created, but can be changed using the -c option.
…
-C comment
Provides a new comment.
-c Requests changing the comment in the private and public key files. This
operation is only supported for RSA1 keys. The program will prompt for
the file containing the private keys, for the passphrase if the key has
one, and for the new comment.
So, when creating the key you use -C "$desiredcommenttext" to provide whatever comment text you like; or for an existing key, use the -c option to change the comment.
Yes! It isn't needed at all, it's just arbitrarily appended to make it easy for you to remember where it came from. If you want to edit it, just open a Terminal session and type:
$ nano ~/.ssh/id_rsa.pub
Remove the end part of the line (after the double-equals).