Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1799218
  • 博文数量: 787
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5015
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-22 15:17
文章分类

全部博文(787)

文章存档

2008年(787)

我的朋友

分类:

2008-09-25 16:06:50

引用:
-(user@host:tty)-(tmp)-
[361 0] %
echo "aA" | grep '[A-Z]$'
aA
-(user@host:tty)-(tmp)-
[361 0] %
echo "aA" | grep '[a-z]$'
-(user@host:tty)-(tmp)-
[361 1] %
echo "aA" | grep '[[:upper:]]$'
aA
-(user@host:tty)-(tmp)-
[361 0] %
echo "aA" | grep '[[:lower:]]$'
-(user@host:tty)-(tmp)-
[361 1] %
bash --version
GNU bash, version 3.00.16(5)-release (powerpc-apple-darwin7.7.0)
Copyright (C) 2004 Free Software Foundation, Inc.
-(user@host:tty)-(tmp)-
[361 0] %
uname -a
Darwin apple.local 8.2.0 Darwin Kernel Version 8.2.0: Fri Jun 24 17:46:54 PDT 2005; root:xnu-792.2.4.obj~3/RELEASE_PPC Power Macintosh powerpc
-(user@host:tty)-(tmp)-
[361 0] %
grep -V
grep (GNU grep) 2.5.1

Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-(user@host:tty)-(tmp)-
[361 0] %

--------------------next---------------------
引用:
-(user@host:tty)-(tmp)-
[3836 0] $
man grep
......

REGULAR EXPRESSIONS
    ......

    Within a bracket expression, a range expression consists of two charac-
    ters separated by a hyphen.  It matches any single character that sorts
    between the two characters, inclusive,  using  the  locale's  collating
    sequence  and  character  set.   For  example, in the default C locale,
    [a-d] is equivalent to [abcd].  Many locales sort characters in dictio-
    nary  order,  and in these locales [a-d] is typically not equivalent to
    [abcd]; it might be equivalent to [aBbCcDd], for  example.
   To  obtain
    the  traditional interpretation of bracket expressions, you can use the
    C locale by setting the LC_ALL environment variable to the value C.
......

-(user@host:tty)-(tmp)-
[3836 0] $
cat file
a
A
z
Z
-(user@host:tty)-(tmp)-
[3836 0] $
LC_ALL=en_US.UTF-8 grep [a-z] file
a
A
z
-(user@host:tty)-(tmp)-
[3836 0] $
LC_ALL=en_US.UTF-8 grep [A-Z] file
A
z
Z
-(user@host:tty)-(tmp)-
[3836 0] $
LC_ALL=C grep [a-z] file
a
z
-(user@host:tty)-(tmp)-
[3836 0] $
LC_ALL=C grep [A-Z] file
A
Z
-(user@host:tty)-(tmp)-
[3836 0] $
LC_ALL=en_US.UTF-8 sort file
a
A
z
Z
-(user@host:tty)-(tmp)-
[3836 0] $
LC_ALL=C sort file
A
Z
a
z
-(user@host:tty)-(tmp)-
[3836 0] $

--------------------next---------------------

阅读(651) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~