免费注册 查看新帖 |

Chinaunix

广告
  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: lightspeed
打印 上一主题 下一主题

[ SHELL 水平测试 ][ SED 篇 ]  关闭 [复制链接]

论坛徽章:
0
11 [报告]
发表于 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.

论坛徽章:
7
荣誉版主
日期:2011-11-23 16:44:17子鼠
日期:2014-07-24 15:38:07狮子座
日期:2014-07-24 11:00:54巨蟹座
日期:2014-07-21 19:03:10双子座
日期:2014-05-22 12:00:09卯兔
日期:2014-05-08 19:43:17卯兔
日期:2014-08-22 13:39:09
12 [报告]
发表于 2005-01-03 11:16 |只看该作者

[ SHELL 水平测试 ][ SED 篇 ]

sed & awk不错,收藏。
谢谢!

论坛徽章:
0
13 [报告]
发表于 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)

论坛徽章:
7
荣誉版主
日期:2011-11-23 16:44:17子鼠
日期:2014-07-24 15:38:07狮子座
日期:2014-07-24 11:00:54巨蟹座
日期:2014-07-21 19:03:10双子座
日期:2014-05-22 12:00:09卯兔
日期:2014-05-08 19:43:17卯兔
日期:2014-08-22 13:39:09
14 [报告]
发表于 2005-01-05 15:34 |只看该作者

[ SHELL 水平测试 ][ SED 篇 ]

手头没有环境测试,建议看一下你的LC_ALL是否设置正确?
我怀疑是它的问题。

论坛徽章:
0
15 [报告]
发表于 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

论坛徽章:
0
16 [报告]
发表于 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相同的值,也如此!

论坛徽章:
7
荣誉版主
日期:2011-11-23 16:44:17子鼠
日期:2014-07-24 15:38:07狮子座
日期:2014-07-24 11:00:54巨蟹座
日期:2014-07-21 19:03:10双子座
日期:2014-05-22 12:00:09卯兔
日期:2014-05-08 19:43:17卯兔
日期:2014-08-22 13:39:09
17 [报告]
发表于 2005-01-05 16:55 |只看该作者

[ SHELL 水平测试 ][ SED 篇 ]

Try
  1. env LANG=C your sed script
  2. or
  3. env LANG=POSIX your sed script
复制代码

论坛徽章:
0
18 [报告]
发表于 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即可。

论坛徽章:
0
19 [报告]
发表于 2005-01-07 16:04 |只看该作者

[ SHELL 水平测试 ][ SED 篇 ]

欧阳兄:
俺不贪心,想要这两本。shaoping0330@163.com
OReilly - Perl Cookbook.pdf
OReilly - Unix in a Nutshell.pdf

论坛徽章:
0
20 [报告]
发表于 2005-01-11 16:28 |只看该作者

[ SHELL 水平测试 ][ SED 篇 ]

shaoping0330   已经发了,请查收;对书贪心也没关系的:)
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP