Linus Torvalds in ascii art easy4/21/2024 ![]() ![]() So we are telling tr that it is going to translate any letter of the alphabet and leave any other character (spaces, punctuation, numbers, etc.) alone. Here A-Z stands for A through Z and a-z stands for a through z (computers treat the capital and lowercase versions of letters as being separate characters). ![]() Second, how exactly did we tell tr to implement ROT13? Well, the first argument, ‘A-Za-z’, gives it a set of characters to work with. Just two more things before moving on to the next command.įirst, the UNIX pipe operator (the “|” character in the commands above, which looks a little bit like a piece of pipe) is plumbing for UNIX commands: it “pipes” the output of one command to the input of a second command. $ echo 'Uryyb guvf vf n grfg' | tr 'A-Za-z' 'N-ZA-Mn-za-m' $ echo 'Hello this is a test' | tr 'A-Za-z' 'N-ZA-Mn-za-m' It is commonly used to make it hard for people to accidentally read spoilers when discussing things like movie plot twists. ROT13 is fun but you would not want to use it for actual secret information since it is trivial to decrypt. Since there are 26 letters, encrypting twice using ROT13 gives back the original text. We’re going to use tr to encrypt some text as ROT13, which simply moves each letter forward in the alphabet by 13 places, wrapping around from Z to A if necessary. Text printed by the system will be on lines not starting with a dollar sign. In this and subsequent examples, I’ll show text that you should type on a line starting with a dollar sign, which is the default UNIX prompt. This will show you the UNIX system’s built-in documentation for the command. To learn more about tr (or any other command in this post) type this command (without typing the dollar sign): It translates the characters in a string into different characters according to rules that you provide. The tr utility should be installed by default on an OS X or Ubuntu machine. This does not require administrator access but it’s more work and I’m not going to go into the details, though I hope to do this in a later post. Build a program from source and install it in your home directory.Other versions of Linux have their own package managers and they are all pretty easy to use. You’ll need administrator access to run Apt or to install Homebrew, but you do not need administrator access to install packages after Homebrew has been installed. Install precompiled binaries using a package manager, I’ll give command lines for Homebrew on OS X and for Apt on Ubuntu Linux.You’ll also need the ability to install software. To run the commands in this post, you’ll need a UNIX machine: either Linux or Mac OS X will work. Keep in mind this immortal scene from Jurassic Park. It is more about having fun than about learning, but I hope that if you enjoy playing around at the UNIX terminal, you’ll eventually learn to use this kind of system for real. This post is aimed at kids, like the 6th graders who I was recently teaching about programming in Python. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |