[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
undocumented \S "joyride" operator
From: |
jidanni |
Subject: |
undocumented \S "joyride" operator |
Date: |
Fri, 15 May 2009 03:22:11 +0800 |
grep 2.5.4 has an undocumented \S operator:
$ echo Full of Shhh|grep ^\\S
Full of Shhh
$ echo Full of Shi|grep \\Sh$
$ echo Full of Shhhh|grep \\Sh$
Full of Shhhh
So you are thinking, "man perlre, Holmes". Well, hah! checkmate:
$ echo Full of Tur|grep \\S
$
\S apparently stands for "throw some rules to the winds", "but only for
some locales".
I discovered this with
$ sh tes|sh -e|grep -v :0
b:237
w:237
S:53
$ cat test
perl -wl <<\EOF
for('a'..'z','A'..'Z'){print "echo -n $_:; grep ^\\\\$_
some_file_with_lots_of_text|grep -v ^$_|wc -l"}
EOF
$ locale
LANG=zh_TW.UTF-8
LC_CTYPE=zh_TW.UTF-8
LC_NUMERIC="zh_TW.UTF-8"
LC_TIME="zh_TW.UTF-8"
LC_COLLATE=C
LC_MONETARY="zh_TW.UTF-8"
LC_MESSAGES=C
LC_PAPER="zh_TW.UTF-8"
LC_NAME="zh_TW.UTF-8"
LC_ADDRESS="zh_TW.UTF-8"
LC_TELEPHONE="zh_TW.UTF-8"
LC_MEASUREMENT="zh_TW.UTF-8"
LC_IDENTIFICATION="zh_TW.UTF-8"
LC_ALL=
If one does
$ export LC_ALL=C; sh tes|sh -e|grep -v :0
the S items disappear, as should be.
I only tested A-Z,a-z. You can test the other \escapes if you like.
- undocumented \S "joyride" operator,
jidanni <=
Re: undocumented \S "joyride" operator, Norihiro Tanaka, 2009/05/15