Chinaunix

标题: [ SHELL 水平测试 ][ SED 篇 ] [打印本页]

作者: lightspeed    时间: 2005-01-01 14:53
标题: [ SHELL 水平测试 ][ SED 篇 ]
按:SHELL 水平测试系列并非覆盖 SHELL 的所有方面,而是挑选一些题目以引发思考,
以管中窥豹的方式达到检验水平的目的.

[ SHELL 水平测试 ][ OVERVIEW 篇 ]
http://bbs.chinaunix.net/forum/viewtopic.php?t=476260&show_type=&sid=e90e3c748f1c10920ca09d71a81f7461

[ SHELL 水平测试 ][ SED 篇 ]
http://bbs.chinaunix.net/forum/viewtopic.php?t=476269&show_type=&sid=e90e3c748f1c10920ca09d71a81f7461

[ SHELL 水平测试 ][ AWK 篇 ]
http://bbs.chinaunix.net/forum/viewtopic.php?t=476271&show_type=&sid=e90e3c748f1c10920ca09d71a81f7461

[ SHELL 水平测试 ][ REGEX 篇 ]
http://bbs.chinaunix.net/forum/viewtopic.php?p=3143773#3143773



[ SHELL 水平测试 ][ SED 篇 ]

1. 你能看懂 sed one-lines 中的每一条语句吗?

2. /regex/! command 与 /regex/ !command 有什么区别?

3. 你能熟练使用 N,n, P,p,D,d,H,h,G,g,x,:,b,t 吗?

4. 什么是 sed 高级编程中的 lookup table 技术

5. sed debuger 的原理是什么?

6. 为什么 sed 的 guru 和 fans 比 awk 的多.(请看 yahoo groups)

下面几题根据使用的技术,难度不同.(难度 最小:1,最大:5)

7. 将数据文件中的每个词的第一个字母变成大写. (难度: 2 - 4)

8. 在 sed 中实现记数器.可加 1 或减 1. (难度: 3 - 4)

9. 提取 html 文件中 table 中每个单员的内容(table 可嵌套).(难度: 4 - 5)

每一个 cell 做为一个单员输出:

Table #1, Row #1, Column #1

Contents .......

Table #1, Row #1, Column #2

Contents .......
作者: ZealeS    时间: 2005-01-01 21:07
标题: [ SHELL 水平测试 ][ SED 篇 ]
汗。。。
N,n, P,p,D,d,H,h,G,g,x,:,b,t至今还不能掌握好。
版主能否指示一下目前那种书对提升shell编写能力比较快。好难找到这方面的书。
作者: lightspeed    时间: 2005-01-02 01:39
标题: [ SHELL 水平测试 ][ SED 篇 ]
原帖由 "ZealeS" 发表:

版主能否指示一下目前那种书对提升shell编写能力比较快。好难找到这方面的书。



O'REILLY:  Learning the Korn Shell, 2nd Edition.
O'REILLY:  sed & awk, Second Edition.
O'REILLY:  Effective AWK Programming, 3rd Edition.
O'REILLY:  Mastering Regular Expressions, 2nd EditionRegular
O'REILLY:  Expression Pocket Reference
Sams Publishing: Unix® Shell Programming, Third Edition
Prentice Hall PTR: Linux Shells by Example
Wicked Cool Shell Scripts: 101 Scripts for Linux, Mac OS X, and Unix Systems
Advanced Bash-Scripting Guide
BASH Frequently-Asked Questions
The GAWK Manual

Please visit shells' home page to get more information for TCSH and ZSH.
作者: r2007    时间: 2005-01-02 12:46
标题: [ SHELL 水平测试 ][ SED 篇 ]
4. 什么是 sed 高级编程中的 lookup table 技术
7. 将数据文件中的每个词的第一个字母变成大写. (难度: 2 - 4)
  1. #!/bin/sed -f
  2. s/$/\naAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/
  3. :a
  4. s/\b\([a-z]\)\(.*\n.*\)\1\(.\)/\3\2\1\3/                                       
  5. ta
  6. s/\n.*//
复制代码


谢谢姚明提醒,已改正!
作者: lightspeed    时间: 2005-01-02 13:16
标题: [ SHELL 水平测试 ][ SED 篇 ]
原帖由 "r2007" 发表:
#!/bin/sed -f
s/$/\naAbBbCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/
:a
s/\b\([a-z]\)\(.*\n.*\)\1\(.\)/\3\2\1\3/                                       
ta
s/\n.*//


不愧为一代宗师啊。
作者: r2007    时间: 2005-01-02 13:31
标题: [ SHELL 水平测试 ][ SED 篇 ]
这个称呼可太大了,我只不过是一个普通的seder而已,热情很高,水平还有待提高。
作者: lightspeed    时间: 2005-01-02 14:05
标题: [ SHELL 水平测试 ][ SED 篇 ]
[quote]原帖由 "r2007"]这个称呼可太大了,我只不过是一个普通的seder而已,热情很高,水平还有待提高。[/quote 发表:


Great !

This is an answer of question 6: 为什么 sed 的 guru 和 fans 比 awk 的多.
作者: ZealeS    时间: 2005-01-03 00:02
标题: [ SHELL 水平测试 ][ SED 篇 ]
http://www.chinalinuxpub.com/doc/oreillybookself/
这里的东东确实很好啊。
作者: lightspeed    时间: 2005-01-03 00:19
标题: [ SHELL 水平测试 ][ SED 篇 ]
原帖由 "ZealeS" 发表:
http://www.chinalinuxpub.com/doc/oreillybookself/
这里的东东确实很好啊。


Obsolete !
作者: ZealeS    时间: 2005-01-03 10:41
标题: [ SHELL 水平测试 ][ SED 篇 ]
哪些东西比较久了吗?哪里有新点的。
作者: lightspeed    时间: 2005-01-03 10:53
标题: [ SHELL 水平测试 ][ SED 篇 ]
[quote]原帖由 "ZealeS"]哪些东西比较久了吗?哪里有新点的。[/quote 发表:


I forgot the site. You can google it and may find some newer
editions but not latest one.
作者: r2007    时间: 2005-01-03 11:16
标题: [ SHELL 水平测试 ][ SED 篇 ]
sed & awk不错,收藏。
谢谢!
作者: shaoping0330    时间: 2005-01-05 14:45
标题: [ SHELL 水平测试 ][ SED 篇 ]
求证:是否是sed的bug???
原帖由 "r2007" 发表:

#!/bin/sed -f
s/$/\naAbBbCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/
:a
s/\b\([a-z]\)\(.*\n.*\)\1\(.\)/\3\2\1\3/                                       
ta
s/\n.*//


把每个单词的首写字母改为大写。上面这个程序略有错误(把小写的c误写为小写b了)。另外,发现一个sed的bug:
$ echo A|sed 's/[A-z]/9/'
9                                    ===???
$ echo A|sed 's/[A-Z]/9/'
9                                    ===正常
$ echo A|sed 's/[a-z]/9/'
9                                    ===不正常
$ echo A|sed 's/[a-Z]/9/'
9                                    ===???

$ echo a|sed 's/[A-z]/9/'
a                                    ===???
$ echo a|sed 's/[a-Z]/9/'
9                                    ===???
$ echo a|sed 's/[a-z]/9/'
9                                    ===正常
$ echo a|sed 's/[A-Z]/9/'
a                                    ===正常

不知为何[a-z]包括了大写字母A。结果导致,如果直接使用r2004的程式将会把全部单词改写为“Z”开头的词,不知各位的机器上是否也如此??

如果换成下面的就很正常了:
s/$/\naAbBbCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/
:a
s/\b\([abcdefghijklmnopqrstuvwxyz]\)\(.*\n.*\)\1\(.\)/\3\2\1\3/                                       
ta
s/\n.*//

GNU sed version 4.0.5
Red Hat Linux release 9 (Shrike)
作者: r2007    时间: 2005-01-05 15:34
标题: [ SHELL 水平测试 ][ SED 篇 ]
手头没有环境测试,建议看一下你的LC_ALL是否设置正确?
我怀疑是它的问题。
作者: 欧阳不修    时间: 2005-01-05 16:08
标题: [ SHELL 水平测试 ][ SED 篇 ]
我有不少oreilly电子书,谁需要我可以发给他
[Oracle University Course - Distributed System Part1 Distributed DB Implement]
[Oracle University Course - Admin Oracle Internet Directory Instructor Guide]
[Oracle University Course - Enterprise Java Developer Student Guide]
[OReilly - Java Enterprise Best Practices]
[OReilly - java.io]
[Oreilly BookShelf - HTML_NO_AD Version - by clong]
[OReilly - The.Linux.Web.Server.CD.Bookshelf.v.1.0]
[OReilly - The.Java.Enterprise.CD.Bookshelf.v.1.0]
[OReilly - The.Web.Developer's.Library.CD]
[OReilly - Using.Samba.1st.Edtion]
[OReilly - XSLT]
[OReilly- Web.Design.CD.Bookshelf.v1.0]
[OReilly.C.Sharp.and.VB.NET.Conversion.Pocket.Reference-CAUDEX]
[OReilly.C.Sharp.Language.Pocket.Reference-CAUDEX]
[OReilly.Objective-C.Pocket.Reference-CAUDEX]
[OReilly.PHP.Pocket.Reference.2nd.Edition-CAUDEX]
[OReilly.sed.and.awk.Pocket.Reference.2nd.Edition-CAUDEX]
[OReilly.The.Networking.CD.Bookshelf.v2.0-ROR]
OReilly - HTTP Pocket Reference 1st Edtion.chm
OReilly - Python Standard Library.chm
OReilly - Learning the Korn Shell, 2nd Edition.pdf
OReilly - Windows Me Annoyances.chm
OReilly - Web Security, Privacy & Commerce, 2nd Edition.chm
OReilly - Practical PostgreSQL.chm
OReilly - Database Porgramming With Jdbc And Java 2nd Edition.pdf
MCSE in a Nutshell.pdf
OReilly - Java Security 2nd Edition.pdf
OReilly - Palm OS Programming - The Developers Guide.pdf
OReilly - Java & Xslt.pdf
OReilly - Web Security & Commerce.chm
XSLT Cookbook.pdf
OReilly - Managing the Windows 2000 Registry.pdf
OReilly - SSH, The Secure Shell - The Definitive Guide Ebook -fly.pdf
OReilly - Internet Core Protocols The Definitive Guide.chm
NET Framework Essentials 2ed.pdf
OReilly - Programming C#, 2nd Edition.pdf
OReilly - Learning Xml.pdf
OReilly - ActionScript for Flash MX - The Definitive Guide, 2nd Edition.chm
OReilly - HTML Pocket Reference 2nd Edition.pdf
OReilly - Practical UNIX and Internet Security.chm
[OReilly.The.Perl.CD.Bookshelf.v3.0-ROR]
OReilly - HTML & XHTML - The Definitive Guide, 4th Ed.pdf
OReilly - SAX2.pdf
OReilly - Linux Device Drivers, 2nd Edition.zip
OReilly - Unix for Oracle DBAs Pocket Reference.pdf
OReilly - Building Internet Firewalls 2nd Edtion.pdf
[tcpip_ill]
OReilly - COM and .NET Component Services.chm
OReilly - Python And Xml.pdf
OReilly - CDO & MAPI Programming with Visual Basic.chm
OReilly - Java Cook Book.pdf
OReilly - Peer to Peer.pdf
OReilly - Access Database Design & Programming 3rdEd.pdf
OReilly - Net Framework Essentials.pdf
OReilly - Web Design in a Nutshell.pdf
OReilly - Access Database Design & Programming, 3rd Edition.chm
OReilly - Dot Net Framework Essentials 2nd Edition.pdf
OReilly - Advanced JAVA Networking.pdf
OReilly - DOT.NET.FRAMEWORK.ESSENTIALS.pdf
OReilly - Xpath And Xpointer.pdf
OReilly - DNS on Windows 2000 2nd edition.pdf
OReilly - Java Programming With Oracle Jdbc.pdf
OReilly - C Pocket Reference.chm
OReilly - Linux poster.pdf
OReilly - Cisco Ios Access Lists.pdf
Java Threads 2ed.pdf
OReilly - Java & XML 2nd Edition.pdf
Access Database Design & Programming 3ed.pdf
OReilly - Java 2d Graphics.pdf
OReilly - Oracle RMAN Pocket Reference.pdf
OReilly - Java programming on  linux.pdf
OReilly - Access Database Design & Programming 2e.pdf
OReilly - Java And Xml.pdf
ASP in a Nutshell.pdf
OReilly - Programming Visual Basic.pdf
OReilly - Developing Java Beans.pdf
Perl & XML.pdf
OReilly - Building Oracle Xml Applications.pdf
OReilly - Learning Perl, Third Edition.chm
OReilly - Java Management Extension.pdf
OReilly - J2ME in a Nutshell.pdf
Dreamweaver in a Nutshell.pdf
OReilly - Programming Cold Fusion Ebook-fly.pdf
OReilly - Learning Oracle PLSQL.chm
OReilly - Running Linux 4th Edition.pdf
OReilly - Manage & Using Mysql.pdf
OReilly - Lingo In A Nutshell.pdf
OReilly - Director In A Nutshell.pdf
OReilly - Java Network Programming, 2nd Edition.pdf
OReilly - Java Programming With Oracle Sqlj.chm
OReilly - (XWindow) Motif Reference Manual 6b.pdf
[OReilly.The.XML.CD.Bookshelf.v1.0-ROR]
OReilly - Linux Network Admin Guide 2nd Edition.pdf
Java Security 2ed.pdf
(O'Reilly) Google Hacks.pdf
OReilly - Java And Xml Binding.pdf
OReilly - .Net Framework Essentials 1st Edtion.pdf
OReilly - Jakarta Struts.pdf
Network Troubleshooting Tools.pdf
OReilly - .Net Framework Essentials 2nd Edition.pdf
OReilly - Managing and Using MySQL, 2nd Edition.chm
[OReilly.VB.NET.Language.Pocket.Reference-CAUDEX]
OReilly - LINUX admin.pdf
OReilly - Beginning Perl For Bioinformatics.pdf
OReilly - C# Essentials, 2nd Edition.pdf
OReilly - Developing ASP Components, 2nd Edition.pdf
OReilly - Oracle sqlloader.pdf
OReilly - Vb & Vba Nutshell.pdf
OReilly - POSIX.4.Programming.for.the.Real.World.eBook-EEn.pdf
OReilly - Programming C#.pdf
Creating Effective Javahelp.pdf
OReilly -  Web Servies Essentials.pdf
OReilly - Vb.net Language In A Nutshell.pdf
OReilly - Java performance tuning.pdf
Google Hacks.pdf
OReilly - (XWindow) Motif Programming Manual 6a.pdf
OReilly - Building Java Enterprise Applications Volume I - Architecture.pdf
OReilly - Dhcp For Windows 2000.pdf
OReilly - Java 3d Programming.pdf
OReilly - Java Servlet Programming.pdf
OReilly - Writing Excel Macros with VBA, 2nd Edition.pdf
OReilly - C Sharp Language Pocket Reference.chm
OReilly - Java And Soap.pdf
OReilly - Java Threads 2nd Edition.pdf
OReilly - C++ in a Nutshell.chm
OReilly - CDO & MAPI Programming with Visual Basic.PDF
OReilly - SQL In Nutshell.pdf
OReilly - sed and awk Pocket Reference - 2nd Edition.chm
OReilly - Delphi In A Nutshell 1st.Ed.pdf
OReilly - Java NIO.pdf
OReilly - JavaServer Pages 2nd Edition.pdf
OReilly - Xml Schema.pdf
OReilly - Mcse In A Nutshell-the Windows 2000 Exams.pdf
OReilly - JavaServer Pages Pocket Reference.pdf
OReilly - Network Troubleshooting Tools.pdf
OReilly - Perl Cookbook.pdf
The C++ Programming Language.tar.gz
OReilly - Unix in a Nutshell.pdf
OReilly - Learning Wml & Wmlscript.pdf
OReilly - Mac OS X For UNIX Geeks.pdf
OReilly - Oracle 8i Interal Service.pdf
OReilly - Programming Web Services With Soap.pdf
OReilly - Macromedia Director In A Nutshell.pdf
[OReily-Enterprise JavaBeans 3rd Ed by flunny]
OReilly - Virtual Private Networks Edt2.pdf
OReilly - Web Caching.chm
OReilly - Access Cookbook.chm
OReilly - ProgrammingPython2ndEd.chm
Java Enterprise Best Practices.pdf
OReilly -  Ant - The Definitive Guide.pdf
JavaServer Pages 2ed.pdf
OReilly - Building Wireless Community Networks.pdf
OReilly - Core JSP.pdf
OReilly - Creating Effective JavaHelp(RoR).pdf
OReilly - Developing Bioinformatics Computer Skills.pdf
OReilly - Enterprise Javabeans 3rd Edition.pdf
OReilly - Essential SNMP.pdf
OReilly - Ethernet The Definitive Guide (2000).pdf
OReilly - Free As In Freedom.pdf
OReilly - Java Cryptography.pdf
OReilly - Java Message Service.pdf
OReilly - Java Rmi.pdf
OReilly - Java server Pages.pdf
OReilly - Java Web Services.pdf
OReilly - Managing Nfs And Nis 2nd Edition.pdf
OReilly - Macromedia Lingo In A Nutshell.pdf
OReilly - Mastering Algorithms with Perl.pdf
OReilly - Mastering Regular Expressions.pdf
OReilly - Network Security with OpenSSL Ebook - Fly.pdf
OReilly - MP3 the definitive guide.pdf
OReilly - Oracle PLSQL Best Practices.pdf
OReilly - Oracle SQL Tuning Pocket Reference.pdf
OReilly - Programming Perl .pdf
OReilly - Programming Perl Dbi.pdf
OReilly - Quickfixes Win2k.pdf
OReilly - Server Load Balancing.pdf
OReilly - Subclassing and Hooking With Visual Basic.pdf
OReilly - Understanding The Linux Kernel 1st Edition.pdf
OReilly - SVG Essential.pdf
OReilly - Understanding The Linux Kernel.pdf
OReilly - Virtual Private Networks 2nd.pdf
OReilly - Visual Basic .NET Language in a Nutshell.pdf
OReilly - Web Services Essentials.pdf
OReilly - Win2k Performance Guide.pdf
OReilly - Windows 2000 Commands Pocket Reference.pdf
OReilly - Xml Pocket Reference.pdf
OReilly-Building Java Enterprise Applications Volume I-.pdf
SAX2.pdf
OReilly - Learning Wireless Java .doc
OReilly - Programming Web Services with XML_RPC.doc
Bruce Schneier - Applied Cryptography.zip
Kernighan and Ritchie - The C Programming Language.zip
M. Abrash - Zen of Graphics Programming.zip
OReilly - MySQL & mSQL.zip
Java Examples in a Nutshell 2nd.rar
Java in a Nutshell 4ed.rar
Java Internationalization.rar
OReilly - Java Swing.rar
OReilly - Learning Java.rar
Randall Hyde - Art Of Assembly.tar.gz
SVG Essentials.rar
UNIX in a Nutshell.tar.gz
Learning Java 2ed.chm
WebMaster in a Nutshell.tar.gz
OReilly - ADO(ActiveX Data Objects).chm
OReilly - Advanced Oracle PLSQL Programming with Packages.chm
OReilly - Apache The Definitive Guide 3rd Edition.chm
OReilly - Apache The Definitive Guide, 2nd Edition.chm
OReilly - ASP dotNET in Nutshell.chm
OReilly - Building Secure Servers with Linux.chm
OReilly - C Sharp and VB.NET Conversion Pocket Reference.chm
OReilly - DNS & BIND Cookbook.chm
OReilly - COM+ Programming with Visual Basic.chm
OReilly - DNS and BIND 4th edition.chm
OReilly - DNS and BIND.chm
OReilly - Essential System Administration Pocket Reference.chm
OReilly - HTTP The Definitive Guide.chm
OReilly - Essential System Administration, 3rd Edition.chm
OReilly - Learning Java, Second Edition.chm
OReilly - Learning Python.chm
OReilly - Learning the bash Shell - 2nd Edition.chm
OReilly - Learning the Unix OS 4th Edition.chm
OReilly - Learning the VI Editor.chm
OReilly - LINUX IN A NUTSHELL, 3RD EDITION.CHM
OReilly - Learning.Oracle.PL-SQL.chm
OReilly - Mastering Visual Studio .NET-Fly.chm
OReilly - MySQL Cookbook.chm
OReilly - Object-Oriented Programming with Visual Basic .NET.chm
OReilly - Objective-C Pocket Reference.chm
OReilly - PHP Cookbook.chm
OReilly - Oracle.Security.OReilly.1998.chm
OReilly - Practical C Programming 3rd Edition.chm
OReilly - PHP Pocket Reference - 2nd Edition.chm
OReilly - Practical C++ Programming.chm
OReilly - Programing Jakarta Struts from Oreilly.chm
OReilly - Programming ASP.NET.chm
OReilly - Programming Embedded Systems in C and C++.chm
OReilly - Programming Jakarta Struts.chm
OReilly - Programming Python, 2nd Edition.chm
OReilly - ProgrammingPHP.chm
OReilly - Python Cookbook.chm
OReilly - Python Pocket Reference, 2nd Edition.chm
OReilly - Python Programming on Win32.chm
OReilly - Python Pocket Reference.chm
OReilly - TCP-IP Networking.chm
OReilly - Understanding the Linux Kernel 2nd Edition.chm
OReilly - UNIX Power Tools 3rd Edition.chm
OReilly - VB & VBA in a Nutshell.chm
OReilly - VB.NET Language Pocket Reference.chm
OReilly - Visual Basic Shell Programming.chm
OReilly - VBScript in a Nutshell.chm
OReilly - Web Database Applications With PHP and MySQL.chm
OReilly - Web Performance Tuning.chm
OReilly - Webmaster in a Nutshell, 2nd Edition.chm
OReilly - Windows 2000 Quick Fixes.chm
OReilly - Windows XP Annoyances.chm
OReilly - Windows XP Pocket Reference.chm
OReilly - Writing Apache Modules with Perl and C.chm
Programming Jakarta Struts.chm
作者: shaoping0330    时间: 2005-01-05 16:09
标题: [ SHELL 水平测试 ][ SED 篇 ]
# locale  (root用户,bash)
LANG=en_US
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE="en_US"
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=
安装后的默认设置,都没有修改。
另外一台机用:
$ locale   (普通用户,bash)
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=


# locale (root用户,tcsh)
LANG=zh_CN.gbk
LC_CTYPE="zh_CN.gbk"
LC_NUMERIC="zh_CN.gbk"
LC_TIME="zh_CN.gbk"
LC_COLLATE="zh_CN.gbk"
LC_MONETARY="zh_CN.gbk"
LC_MESSAGES="zh_CN.gbk"
LC_PAPER="zh_CN.gbk"
LC_NAME="zh_CN.gbk"
LC_ADDRESS="zh_CN.gbk"
LC_TELEPHONE="zh_CN.gbk"
LC_MEASUREMENT="zh_CN.gbk"
LC_IDENTIFICATION="zh_CN.gbk"
LC_ALL=

分布运行那个sed脚本文件,最后全部都把单词的第一个字母替换为Z!其间,分别把LC_ALL设置为同LANG相同的值,也如此!
作者: r2007    时间: 2005-01-05 16:55
标题: [ SHELL 水平测试 ][ SED 篇 ]
Try
  1. env LANG=C your sed script
  2. or
  3. env LANG=POSIX your sed script
复制代码

作者: shaoping0330    时间: 2005-01-06 17:41
标题: [ SHELL 水平测试 ][ SED 篇 ]
多谢r2007兄,小弟又长见识了!

现在知道了,通常我们的区域化资料库,即locale查看时,有:
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE=C
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

多项,其优先顺序为 LC_ALL >LC_*>LANG,其中:
LC_COLLATE=C  代表文字排序规则及正则表达式的比较依据
其他是一些时间、地址、货币、数字等表示方式。
所以,实际上只要修改LC_COLLATE即可。
作者: shaoping0330    时间: 2005-01-07 16:04
标题: [ SHELL 水平测试 ][ SED 篇 ]
欧阳兄:
俺不贪心,想要这两本。shaoping0330@163.com
OReilly - Perl Cookbook.pdf
OReilly - Unix in a Nutshell.pdf
作者: 欧阳不修    时间: 2005-01-11 16:28
标题: [ SHELL 水平测试 ][ SED 篇 ]
shaoping0330   已经发了,请查收;对书贪心也没关系的:)




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2