Jul 1, 2015

Linux: Inserting ASCII Characters


Sometimes you need run a command and pipe the output with some tool like 'grep', this is simple and common, but might not be if you are using a keyboard without the desired character or with a layout that doesn't support it, and then what to do? Look here some ways to insert any ASCII character in the Linux.

Some developers and advanced users memorize the most used ASCII characters, like pipe "|" (ASCII 124) and backslash "\" (ASCII 92), in the Windows world  you just press ALT + ASCII number and then it appear. But in the Linux world you need the hexadecimal number, so the pipe is 0x7C and backslash 0x5C. Using the pipe as example, look below some ways.

Method 1 - Manually Typing

This method will work in the terminal as well as GUI applications like Gedit, Firefox and so on. To insert just type CTRL + SHIFT + U then the ASCII hexadecimal number, when finish hit enter. So now I need memorize the hexadecimal too? not really, you can find an ASCII table and do a quick search with the following command:

man ascii

Method 2 - Command / Script

This method fits better with scripts, using the "echo" command:

echo -e "\x7C"
|

Method 3 - Simple and Universal

This method is simple and can be used with any system, not only with Linux. Keep some file with the most used ASCII characters as content, and when you need use one of them, just copy from the file and paste where you need !

0 comentários :

Post a Comment