I cannot believe how many times I've see people laboriously copy a few lines at a time, paste them into their terminal window, wait (9600 8 N 1 only goes so fast, y'all.), copy a few more. I mentioned serial connections at the beginning of this. Important note for sysadmins and especially network people bash: ztn1etic2Iki7r/ugczUKM68Lh893ENmSgAAAA=: No such file or directory" :P). Ask me how many times I've seen " -bash: H4sIAAAAAAACAxXJQQ6AIA圎0b2nmJu49RoVxmgiLaFFw+2V3X/5m71IooiTUAakWNeAHaBGszpm: No such file or directory on the other hand, at least your shell history will only have one bogus entry on accidental paste instead of 150. It can make the copy/pasting more error-prone, as it's easier to miss a single character somewhere (and if you accidentally paste it in the wrong place, it makes more of a mess.4096 bytes per line is a common threshold at which something barfs.Even if the base64 command is OK with it, sometimes the terminal program isn't.Some implementations are buggy when it comes to very long lines (the opposite problem of the earlier caveat).You can also scrunch down the base64 a little more by setting the line-width to unlimited ( base64 -w 0), but be aware that: (For very small inputs, gzip often produces slightly fewer bytes than xz and even zstd, plus it's available practically everywhere.) (Incidentally, if the block of text you want is really small or your local one is very similar already, you can skip the base64 and just edit it manually and just use md5sum to confirm you got it right.) If your file or block of text is longer than a screenful (You'll want to undo the encode step on the source system, obviously.)ĭon't believe me that it's 100% binary identical? Select the text blocks on both sides and check: Shift+V to go to visual select line mode select the block you wantĬopy & paste the block into your other vim, then select the base64 textĪnd there it is, in all its tabular/nonprinting/emoji/16-bit-big-endian-unicode-because-why-not glory. Suppose you're editing a file locally and you want to copy a piece of a remote file, and it's very important to exactly preserve the indenting and whitespace (because it's python, yaml, or you've forgotten about ":set paste" in vim and internalised the notion that auto-indent is forever.but "set paste" doesn't help you with tabs not surviving a terminal display anyway). I use this sometimes when I can't be arsed to deal with sudo/ chmod/ chown when copying a file between sessions running as different restricted users, or across a chroot, container, VM, etc. I have seen this behaviour primarily on old Gentoo boxes, Solaris, and ancient versions of CentOS and Red Hat.ĭoesn't even have to be a remote system of course. In that case, try base64 -di as the decode command - for some weird reason, certain versions of the base64 utility can't even decode their own input by default, because they decide to insert newlines on encode, but barf immediately on any non-base64 character on decode.including newlines. * The caveat: sometimes you'll run into this on decode: "base64: invalid input". Now paste the text, press enter, then ctrl+d when you're done, and you have a binary-identical copy of the file on your local system, regardless of how many spaces, newlines, and messed up terminal wrapping you copied. Now you don't have to worry about formatting at all*! Just copy all the base64 text as a block, and on the receive side: base64 -d > nf_from_remote ![]() ![]() ![]() ![]() Instead of copy/pasting it a bit at a time, or trying to make your scrollback buffer and text wrapping cooperate (and still convert tabs to weird numbers of spaces.), you can: You've ssh'd all the way there, but were lazy and didn't bother port-forwarding (if that's even allowed), and now you need to get a copy of some config file. Suppose there's some system you connect to through a VPN and then two jump boxes.Well, that still works, and the commands needed to encode/decode it are installed by default pretty much everywhere, so that means you can. Here's another example of "what's old is new again" - remember how a long time ago, you interacted with a modem by giving it textual commands, and then it connected you to distant machines, which you also spoke to in text, and when you wanted to send and receive binary files, you had to encode those as text too?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |