Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
12-01-2012, 07:40 PM
|
#1
|
|
Member
Registered: Jul 2009
Location: Montaletto
Distribution: Debian GNU/Linux
Posts: 75
Rep:
|
Bash: $'\x00' -- What is this?
Our super-modern commerce-oriented web search engines are simply too stupid to allow programmers to search information about specific sequences of symbols... Well, this is why I search for a solution here.
I came across a totally new, never-seen-before Bash expansion or substitution; this is constituted of sequences of characters like
What it does is the replacement of the UTF-8 bytes sequence with the represented character.
I've never seen this in Bash's manual (and I'm leaned to think this is not described there at all) nor everywhere else.
Do you have any information on this construct, such as its name, or a document where this is described?
|
|
|
|
12-02-2012, 02:51 AM
|
#2
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,703
|
Those are hexadecimal eight-bit characters that can be used by many programs. Have a look at man ascii for their specific meaning.
This from the bash man page;
Code:
Words of the form $'string' are treated specially. The word expands to
string, with backslash-escaped characters replaced as specified by the
ANSI C standard. Backslash escape sequences, if present, are decoded
as follows:
\a alert (bell)
\b backspace
\e
\E an escape character
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\' single quote
\" double quote
\nnn the eight-bit character whose value is the octal value
nnn (one to three digits)
\xHH the eight-bit character whose value is the hexadecimal
value HH (one or two hex digits)
\cx a control-x character
The expanded result is single-quoted, as if the dollar sign had not
been present.
Example:
Code:
# using hexadecimal values
$ echo $'\x21\x22\x23'
!"#
# using octal values:
$ echo '!~' | tr '\041\176' 'X'
XX
PS: They are not UTF-8 specific.
|
|
|
1 members found this post helpful.
|
12-02-2012, 07:39 AM
|
#3
|
|
Member
Registered: Jul 2009
Location: Montaletto
Distribution: Debian GNU/Linux
Posts: 75
Original Poster
Rep:
|
Thank you, that's very useful. I didn't know the we had a man ascii too.
If only there was an effective way to parse across man pages..
|
|
|
|
12-02-2012, 08:35 AM
|
#4
|
|
Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 643
Rep: 
|
You will note that the first character is 0x00 - which is null. The sequence is the hex representation of a specific UTF32 glyph. Interpretation of the sequence is under the control of the font being used by the terminal emulator...
|
|
|
|
12-02-2012, 08:51 AM
|
#5
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,703
|
Quote:
Originally Posted by romagnolo
Thank you, that's very useful. I didn't know the we had a man ascii too.
If only there was an effective way to parse across man pages..
|
You do know that you can search all the man pages present on your box?
Code:
$ man -k utf-8
utf8 (7) - an ASCII compatible multibyte Unicode encoding
FcStrCmp (3) - compare UTF-8 strings
FcStrCmpIgnoreCase (3) - compare UTF-8 strings ignoring case
FcStrStr (3) - locate UTF-8 substring
FcStrStrIgnoreCase (3) - locate UTF-8 substring ignoring ASCII case
FcUcs4ToUtf8 (3) - convert UCS4 to UTF-8
FcUtf8Len (3) - count UTF-8 encoded chars
FcUtf8ToUcs4 (3) - convert UTF-8 to UCS4
utf-8 (7) - an ASCII compatible multibyte Unicode encoding
uxterm (1) - X terminal emulator for Unicode (UTF-8) environments
$ man -k ascii
aaxine (1) - an ASCII art video player
ascii (7) - the ASCII character set encoded in octal, decimal, and hexadecimal
asciitopgm (1) - convert ASCII graphics into a portable graymap
asctime (3) - transform date and time to broken-down time or ASCII
asctime_r (3) - transform date and time to broken-down time or ASCII
ctime (3) - transform date and time to broken-down time or ASCII
.
.
.
strtold (3) - convert ASCII string to floating-point number
toascii (3) - convert character to ASCII
utf-8 (7) - an ASCII compatible multibyte Unicode encoding
utf8 (7) - an ASCII compatible multibyte Unicode encoding
man man for details (Yes, there's a man page for the man page  ).
|
|
|
2 members found this post helpful.
|
12-03-2012, 03:26 AM
|
#6
|
|
Guru
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.4, Centos 5.9
Posts: 14,973
|
... and if you don't like computerese eg switches (-k), there normally is an alias 'apropos=man -k', thus
returns the same answers 
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:42 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|