增加内存表的使用空间
如何增加内存表的使用空间
this is how to change it with my.cnf
/usr/local/mysql/bin/mysqld_safe –user=mysql -O max_heap_table_size=320M &
默认的是16M,可以根据自己的需要,增加到需要的大小
如何增加内存表的使用空间
this is how to change it with my.cnf
/usr/local/mysql/bin/mysqld_safe –user=mysql -O max_heap_table_size=320M &
默认的是16M,可以根据自己的需要,增加到需要的大小
Check here
Interactive session from MySQL Camp I:
Specific Query Performance Tips (see also database design tips for tips on indexes):
Scaling Performance Tips:
Network Performance Tips:
OS Performance Tips:
MySQL Server Overall Tips:
Storage Engine Performance Tips:
Database Design Performance Tips:
Other:
Jay Pipes, Sheeri Kritzer, Bill Karwin, Ronald (”Jeremy Basher”) Bradford, Farhan “Frank Mash” Mashraqi, Taso Du Val, Ron Hu, Klinton Lee, Rick James, Alan Kasindorf, Eric Bergen, Kaj Arno, Joel Seligstein, Amy Lee
{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\nowidctlpar\fi-4800\li4800\b\f0\fs20 Main >> Installing port in /usr/ports/converters/php5-mbstring\par
\par
Installing port in /usr/ports/converters/php5-mbstring\par
===> Vulnerability check disabled, database not found\par
=> php-5.2.6.tar.bz2 doesn’t seem to exist in /usr/ports/distfiles/.\par
=> Attempting to fetch from http://br.php.net/distributions/.\par
php-5.2.6.tar.bz2 9346 kB 317 kBps\par
===> Extracting for php5-mbstring-5.2.6\par
=> MD5 Checksum OK for php-5.2.6.tar.bz2.\par
=> SHA256 Checksum OK for php-5.2.6.tar.bz2.\par
===> Patching for php5-mbstring-5.2.6\par
===> Applying FreeBSD patches for php5-mbstring-5.2.6\par
===> php5-mbstring-5.2.6 depends on file: /usr/local/bin/phpize - found\par
===> php5-mbstring-5.2.6 depends on file: /usr/local/bin/autoconf-2.61 - found\par
===> PHPizing for php5-mbstring-5.2.6\par
Configuring for:\par
PHP Api Version: 20041225\par
Zend Module Api No: 20060613\par
Zend Extension Api No: 220060519\par
===> Configuring for php5-mbstring-5.2.6\par
configure: WARNING: you should use –build, –host, –target\par
checking for grep that handles long lines and -e… /usr/bin/grep\par
checking for egrep… /usr/bin/grep -E\par
checking for a sed that does not truncate output… /bin/sed\par
checking for amd64-portbld-freebsd6.2-gcc… cc\par
checking for C compiler default output file name… a.out\par
checking whether the C compiler works… yes\par
checking whether we are cross compiling… no\par
checking for suffix of executables… \par
checking for suffix of object files… o\par
checking whether we are using the GNU C compiler… yes\par
checking whether cc accepts -g… yes\par
checking for cc option to accept ISO C89… none needed\par
checking whether cc understands -c and -o together… yes\par
checking for system library directory… lib\par
checking if compiler supports -R… yes\par
checking build system type… amd64-portbld-freebsd6.2\par
checking host system type… amd64-portbld-freebsd6.2\par
checking target system type… amd64-portbld-freebsd6.2\par
checking for PHP prefix… /usr/local\par
checking for PHP includes… -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib\par
checking for PHP extension directory… /usr/local/lib/php/extensions/no-debug-non-zts-20060613\par
checking for PHP installed headers prefix… /usr/local/include/php\par
checking for re2c… re2c\par
checking for re2c version… 0.13.3 (ok)\par
checking for gawk… no\par
checking for nawk… nawk\par
checking if nawk is broken… no\par
checking whether to enable multibyte string support… yes, shared\par
checking whether to enable multibyte regex support… yes\par
checking whether to check multibyte regex backtrack… yes\par
checking for external libmbfl… no\par
checking how to run the C preprocessor… cc -E\par
checking for ANSI C header files… yes\par
checking for sys/types.h… yes\par
checking for sys/stat.h… yes\par
checking for stdlib.h… yes\par
checking for string.h… yes\par
checking for memory.h… yes\par
checking for strings.h… yes\par
checking for inttypes.h… yes\par
checking for stdint.h… yes\par
checking for unistd.h… yes\par
checking for variable length prototypes and stdarg.h… yes\par
checking for stdlib.h… (cached) yes\par
checking for string.h… (cached) yes\par
checking for strings.h… (cached) yes\par
checking for unistd.h… (cached) yes\par
checking sys/time.h usability… yes\par
checking sys/time.h presence… yes\par
checking for sys/time.h… yes\par
checking sys/times.h usability… yes\par
checking sys/times.h presence… yes\par
checking for sys/times.h… yes\par
checking stdarg.h usability… yes\par
checking stdarg.h presence… yes\par
checking for stdarg.h… yes\par
checking for int… yes\par
checking size of int… 4\par
checking for short… yes\par
checking size of short… 2\par
Main >> DNS Functions >> Edit MX Entry
/var/spool/exim/msglog/6
Current MX Entries
Domain MX Entry Always Accept
hobid.com 0 hobid.com Delete
20 alt1.aspmx.l.google.com Delete
No Set To Yes
Main >> Service Configuration >> Exim Configuration Editor
Exim Configuration Editor
Configuration file passes test! New configuration file was installed.
Enabled system filter options: attachments|fail_spam_score_over_200|spam_rewrite
Enabled ACL options in block ACL_RATELIMIT_BLOCK: 0tracksenders
Enabled ACL options in block ACL_RATELIMIT_SPAM_BLOCK: ratelimit_spam_score_over_200
Enabled ACL options in block ACL_RBL_BLOCK:
Enabled ACL options in block ACL_PRE_RECP_VERIFY_BLOCK: dictionary_attack
Enabled ACL options in block ACL_NOTQUIT_BLOCK: ratelimit
Enabled ACL options in block ACL_TRUSTEDLIST_BLOCK:
Enabled ACL options in block ACL_CONNECT_BLOCK: ratelimit|spammerlist
Enabled ACL options in block ACL_SPAM_BLOCK: deny_spam_score_over_200
Detected spam handling in acls, disabling spamassassin in routers & transports!.
SpamAssassin method remains unchanged
Configured options list is:
Provided options list is: hostlist senderverifybypass_hosts|hostlist skipsmtpcheck_hosts|hostlist spammeripblocks|hostlist backupmx_hosts|hostlist trustedmailhosts|domainlist user_domains|smtp_receive_timeout|ignore_bounce_errors_after|timeout_frozen_after|auto_thaw|callout_domain_negative_expire|callout_negative_expire|acl_smtp_connect|acl_smtp_notquit|spamd_address
Exim Insert Regex is: virtual_userdelivery|virtual_aliases|lookuphost|virtual_user|address_pipe|localuser
Exim Replace Regex is: virtual_sa_user|sa_localuser|virtual_sa_userdelivery|local_sa_delivery|central_filter|central_user_filter|democheck|fail_remote_domains|has_alias_but_no_mailbox_discarded_to_prevent_loop|literal|local_delivery|local_delivery_spam|localuser|localuser_spam|lookuphost|remote_smtp|userforward|virtual_aliases|virtual_aliases_nostar|virtual_user|virtual_user_spam|virtual_userdelivery|virtual_userdelivery_spam
Exim Match Insert Regex is: quota_directory|maildir_format
Exim version 4.69 #0 (FreeBSD 6.2) built 04-Jun-2008 21:38:13
Copyright (c) University of Cambridge 2006
Probably Berkeley DB version 1.8x (native mode)
Support for: crypteq iconv() IPv6 use_setclassresources PAM Perl Expand_dlfunc OpenSSL Content_Scanning Old_Demime
Lookups: lsearch wildlsearch nwildlsearch iplsearch cdb dbm dbmnz dnsdb dsearch nis nis0 passwd
Authenticators: cram_md5 dovecot plaintext spa
Routers: accept dnslookup ipliteral manualroute queryprogram redirect
Transports: appendfile/maildir/mailstore/mbx autoreply lmtp pipe smtp
Fixed never_users: 0
Size of off_t: 8
Exim Perl Load List is: spam_acl_support|checkuserquota|boxtrapper|safefile|fast_checkvalias|checkspam|checkspam2|fast_isdemo|fast_accountfunc|checkpass_cphulkd
/etc/exim.pl.local installed!
razor2 is not installed, disabling it in SpamAssassin to save memory
pyzor is not installed, disabling it in SpamAssassin to save memory
SPF is disabled in exim or unavailable, enabling SPF for SpamAssassin
Attempting to restart exim
Waiting for exim to restart…. . . . . . . . . . . finished.
exim statusmailnull 26474 0.0 0.1 15896 3484 ?? Ss 3:15PM 0:00.00 /usr/local/sbin/exim -bd -q30m (exim-4.69-0)
mailnull 26477 0.0 0.1 15896 3448 ?? Ss 3:15PM 0:00.00 /usr/local/sbin/exim -tls-on-connect -bd -oX 465 (exim-4.69-0)
exim started ok
Your configuration changes have been saved!
Main >> Hostname A Entry Missing!
Hostname A Entry Missing!
The server was unable to lookup an an A entry for its hostname (newinst.layeredtech.com). This is generally because the entry was never added. However this could also be the result of your nameserver(s) being down. If you would like to attempt to automatically add the entry, .
Main >> Software >> Update Server Software
Update Server Software
cPanel Package Upgrades in Progress…
Ftp Setup Script Version 6.1
This is the pure-ftpd installer
Searching ports for pure-ftpd ……………………………….found pure-ftpd in /usr/ports/ftp/pure-ftpd….Done
pure-ftpd (1.0.21-2) is already installed.
MySQL Setup Script Version 7.0
This is the MySQL installer for OS FreeBSD
Searching ports for mysql50-client ………………………..found mysql50-client in /usr/ports/databases/mysql50-client….Done
mysql50-client (5.0.51a) is already installed.
Searching ports for mysql50-server ………………………..found mysql50-server in /usr/ports/databases/mysql50-server….Done
mysql50-server (5.0.51a) is already installed.
Install Complete
bandmin Setup Script Version 1.0
courier-imap Setup Script Version 1.0
This is the courier-imap installer for OS FreeBSD
Source: packages-6.2-release
looking up ftp5.de.freebsd.org
connecting to ftp5.de.freebsd.org:21
fetch: ftp://ftp5.de.freebsd.org/pub/FreeBSD/ports/amd64/packages-6.2-release/INDEX: Operation timed out
Source: packages-6-stable
looking up ftp5.de.freebsd.org
connecting to ftp5.de.freebsd.org:21
fetch: ftp://ftp5.de.freebsd.org/pub/FreeBSD/ports/amd64/packages-6-stable/INDEX: Operation timed out
Source: packages-6.2-release
looking up ftp.ua.freebsd.org
connecting to ftp.ua.freebsd.org:21
binding data socket
initiating transfer
remote size / mtime: 8252233 / 1164048316
/root/.cpbsdpkgs/6-8-2008.INDEX 8058 kB 380 kBps
gdbm (1.8.3_2) is already installed.
Searching ports for courier-authlib ……………………………………………………….found courier-authlib in /usr/ports/security/courier-authlib….Done
courier-authlib (0.60.2) is already installed.
Searching ports for courier-imap ………………………………………..found courier-imap in /usr/ports/mail/courier-imap….Done
courier-imap (4.3.1,2) is already installed.
No restart required
Install Complete
Exim (maildir) Setup Script Version 20.0
exim (4.69) is already installed.
exim (4.69) is already installed.
Searching ports for portupgrade …………………………………………………..found portupgrade in /usr/ports/ports-mgmt/portupgrade….Done
portupgrade (2.4.3-2,2) is already installed.
openssh is installed
exim is installed
rdate is installed
bash is installed
ncftp is installed
wget is installed
jpeg is installed
python is installed
imap-uw is installed
png is installed
我直接调用函数:mb_convert_encoding();却提示此函数未定义,”Call to undefined function:mb_convert_encoding()”,
1、需要加载php_mbstring扩展
2、windows下修改php.ini文件
把;extension=php_mbstring.dll前的分号去掉,重起apache
64位技术:这里的64位技术是相对于32位而言的,这个位数指的是CPU GPRs(General-Purpose Registers,通用寄存器)的数据宽度为64位,64位指令集就是运行64位数据的指令,也就是说处理器一次可以运行64bit数据。64bit处理器并非现在才有的,在高端的RISC(Reduced Instruction Set Computing,精简指令集计算机)很早就有64bit处理器了,比如SUN公司的UltraSparc Ⅲ、IBM公司的POWER5、HP公司的Alpha等。
64bit计算主要有两大优点:可以进行更大范围的整数运算;可以支持更大的内存。不能因为数字上的变化,而简单的认为64bit处理器的性能是32bit处理器性能的两倍。实际上在32bit应用下,32bit处理器的性能甚至会更强,即使是64bit处理器,目前情况下也是在32bit应用下性能更强。所以要认清64bit处理器的优势,但不可迷信64bit。
要实现真正意义上的64位计算,光有64位的处理器是不行的,还必须得有64位的操作系统以及64位的应用软件才行,三者缺一不可,缺少其中任何一种要素都是无法实现64位计算的。目前,在64位处理器方面,Intel和AMD两大处理器厂商都发布了多个系列多种规格的64位处理器;而在操作系统和应用软件方面,目前的情况不容乐观。因为真正适合于个人使用的64位操作系统现在就只有Windows XP X64,而Windows XP X64本身也只是一个过渡性质的64位操作系统,在Windows Vista发布以后就将被淘汰,而且Windows XP X64本身也不太完善,易用性不高,一个明显的例子就是各种硬件设备的驱动程序很不完善,而且现在64位的应用软件还基本上没有,确实硬件厂商和软件厂商也不愿意去为一个过渡性质的操作系统编写驱动程序和应用软件。所以要想实现真正的64位计算,恐怕还得等到Windows Vista普及一段时间之后才行。
目前主流CPU使用的64位技术主要有AMD公司的AMD64位技术、Intel公司的EM64T技术、和Intel公司的IA-64技术。其中IA-64是Intel独立开发,不兼容现在的传统的32位计算机,仅用于Itanium(安腾)以及后续产品Itanium 2,一般用户不会涉及到,因此这里仅对AMD64位技术和Intel的EM64T技术做一下简单介绍。
AMD64位技术X86-64:
AMD64的位技术是在原始32位X86指令集的基础上加入了X86-64扩展64位X86指令集,使这款芯片在硬件上兼容原来的32位X86软件,并同时支持X86-64的扩展64位计算,使得这款芯片成为真正的64位X86芯片。这是一个真正的64位的标准,X86-64具有64位的寻址能力。
X86-64新增的几组CPU寄存器将提供更快的执行效率。寄存器是CPU内部用来创建和储存CPU运算结果和其它运算结果的地方。标准的32-bit x86架构包括8个通用寄存器(GPR),AMD在X86-64中又增加了8组(R8-R9),将寄存器的数目提高到了16组。X86-64寄存器默认位64-bit。还增加了8组128-bit XMM寄存器(也叫SSE寄存器,XMM8-XMM15),将能给单指令多数据流技术(SIMD)运算提供更多的空间,这些128位的寄存器将提供在矢量和标量计算模式下进行128位双精度处理,为3D建模、矢量分析和虚拟现实的实现提供了硬件基础。通过提供了更多的寄存器,按照X86-64标准生产的CPU可以更有效的处理数据,可以在一个时钟周期中传输更多的信息。
EM64T技术
Intel官方是给EM64T这样定义的:EM64T全称Extended Memory 64 Technology,即扩展64bit内存技术。EM64T是Intel IA-32架构的扩展,即IA-32e(Intel Architectur-32 extension)。IA-32处理器通过附加EM64T技术,便可在兼容IA-32软件的情况下,允许软件利用更多的内存地址空间,并且允许软件进行32 bit线性地址写入。EM64T特别强调的是对32 bit和64 bit的兼容性。Intel为新核心增加了8个64 bit GPRs(R8-R15),并且把原有GRPs全部扩展为64 bit,这样可以提高整数运算能力。增加8个128bit SSE寄存器(XMM8-XMM15),是为了增强多媒体性能,包括对SSE、SSE2和SSE3的支持。
Intel为支持EM64T技术的处理器设计了两大模式:传统IA-32模式(legacy IA-32 mode)和IA-32e扩展模式(IA-32e mode)。在支持EM64T技术的处理器内有一个称之为扩展功能激活寄存器(extended feature enable register,IA32_EFER)的部件,其中的Bit10控制着EM64T是否激活。Bit10被称作IA-32e模式有效(IA-32e mode active)或长模式有效(long mode active,LMA)。当LMA=0时,处理器便作为一颗标准的32 bit(IA32)处理器运行在传统IA-32模式;当LMA=1时,EM64T便被激活,处理器会运行在IA-32e扩展模式下。
目前AMD方面支持64位技术的CPU有Athlon 64系列、Athlon FX系列和Opteron系列。Intel方面支持64位技术的CPU有使用Nocona核心的Xeon系列、使用Prescott 2M核心的Pentium 4 6系列和使用Prescott 2M核心的P4 EE系列。
浅谈 EM64T技术和AMD64区别X86-64 (AMD64 / EM64T) :
AMD公司设计,可以在同一时间内处理64位的整数运算,并兼容于X86-32架构。其中支持64位逻辑定址,同时提供转换为32位定址选项;但数据操作指令默认为32位和8位,提供转换成64位和16位的选项;支持常规用途寄存器,如果是32位运算操作,就要将结果扩展成完整的64位。这样,指令中有“直接执行”和“转换执行”的区别,其指令字段是8位或32位,可以避免字段过长。
x86-64(AMD64)的产生也并非空穴来风,x86处理器的32bit寻址空间限制在4GB内存,而IA-64的处理器又不能兼容x86。 AMD充分考虑顾客的需求,加强x86指令集的功能,使这套指令集可同时支持64位的运算模式,因此AMD把它们的结构称之为x86-64。在技术上 AMD在x86-64架构中为了进行64位运算,AMD为其引入了新增了R8-R15通用寄存器作为原有X86处理器寄存器的扩充,但在而在32位环境下并不完全使用到这些寄存器。原来的寄存器诸如EAX、EBX也由32位扩张至64位。在SSE单元中新加入了8个新寄存器以提供对SSE2的支持。寄存器数量的增加将带来性能的提升。与此同时,为了同时支持32和64位代码及寄存器,x86-64架构允许处理器工作在以下两种模式:Long Mode(长模式)和Legacy Mode(遗传模式),Long模式又分为两种子模式(64bit模式和Compatibility mode兼容模式)。该标准已经被引进在AMD服务器处理器中的Opteron处理器。
而今年也推出了支持64位的EM64T技术,再还没被正式命为EM64T之前是IA32E,这是英特尔64位扩展技术的名字,用来区别X86指令集。Intel的EM64T支持64位sub-mode,和AMD的X86-64技术类似,采用64位的线性平面寻址,加入8个新的通用寄存器(GPRs),还增加8个寄存器支持SSE指令。与AMD相类似,Intel的64位技术将兼容IA32和IA32E,只有在运行64位操作系统下的时候,才将会采用IA32E。IA32E将由2个sub-mode组成:64位sub-mode和32位sub-mode,同AMD64一样是向下兼容的。 Intel的EM64T将完全兼容AMD的X86-64技术。现在Nocona处理器已经加入了一些64位技术,Intel的Pentium 4E处理器也支持64位技术。
应该说,这两者都是兼容x86指令集的64位微处理器架构,但EM64T与AMD64还是有一些不一样的地方,AMD64处理器中的NX位在Intel的处理器中将没有提供。
Grep的常用命令语法1. 双引号引用和单引号引用
在g r e p命令中输入字符串参数时,最好将其用双引号括起来。例如:”m y s t r i n g”。这样做有两个原因,一是以防被误解为 s h e l l命令,二是可以用来查找多个单词组成的字符串,例如:”jet plane”,如果不用双引号将其括起来,那么单词 p l a n e将被误认为是一个文件,查询结果将返回”文件不存在”的错误信息。
在调用变量时,也应该使用双引号,诸如: g r e p”$ M Y VA R”文件名,如果不这样,将
没有返回结果。
在调用模式匹配时,应使用单引号.[root@mypc ]# echo `grep 123 111.txt` (#注意是反单引号)
2. 常用的g r e p选项有:
-c 只输出匹配行的计数。
-i 不区分大小写(只适用于单字符)。
-h 查询多文件时不显示文件名。
-l 查询多文件时只输出包含匹配字符的文件名。
-n 显示匹配行及行号。
-s 不显示不存在或无匹配文本的错误信息。
-v 显示不包含匹配文本的所有行。
3. 特殊的–在多个文件中进行查询
$ grep “sort”*.doc ( #在当前目录下所有. d o c文件中查找字符串”s o r t”)
$ grep “sort it” * (#或在所有文件中查询单词”sort it”)
接下来的所有示例是指在单个文件中进行查询
4. 行匹配
$ grep -c “48″ data.f
$ 4 (#g r e p返回数字4,意义是有4行包含字符串”4 8″。)
$ grep “48″ data.f (#显示包含”4 8″字符串的4行文本)
5. 显示满足匹配模式的所有行行数:
[root@mypc oid2000]# grep -n 1234 111.txt
1:1234
3:1234ab
6. 精确匹配
[root@mypc oid2000]# grep “1234\>” 111.txt
1234
7. 查询空行,查询以某个条件开头或者结尾的行。
结合使用^和$可查询空行。使用- n参数显示实际行数
[root@mypc oid2000]# grep -n “^$” 111.txt (返回结果 2: #说明第二行是空行)
[root@mypc oid2000]# grep -n “^abc” 111.txt (#查询以abc开头的行)
[root@mypc oid2000]# grep -n “abc$” 111.txt (#查询以abc结尾的行)
8. 匹配特殊字符,查询有特殊含义的字符,诸如$ . ‘ ” * [] ^ | \ + ? ,必须在特定字符前加\。
[root@mypc oid2000]# grep “\.” 111.txt (#在111.txt中查询包含”.”的所有行)
[root@mypc oid2000]# grep “my\.conf” 111.txt (#查询有文件名my. c o n f的行)
9. 目录的查询
[root@mypc oid2000]# ls -l |grep “^d” (#如果要查询目录列表中的目录)
[root@mypc oid2000]# ls -l |grep “^d[d]” (#在一个目录中查询不包含目录的所有文件)
[root@mypc]# ls -l |grpe “^d…..x..x” (#查询其他用户和用户组成员有可执行权限的目录集合)
Awk的常用命令语法
awk命令擅长格式化报文或从一个大的文本文件中抽取数据包,下面是该命令的基本语法
awk [-F filed-separator] “commands” input-file(s)
[ - F域分隔符]是可选的,a w k使用空格作为缺省的域分隔符,如果在要处理的文件中是以冒号作为分割域的(如passwd文件),则在处理的时候要这样指明 awk -F: command input-file(s)
1.1域和记录
a w k执行时,其浏览域标记为$ 1,$ 2 . . . $ n。这种方法称为域标识。使用$ 1 , $ 3表示参照第1和第3域,注意这里用逗号做域分隔。如果希望打印一个有 5个域的记录的所有域,不必指明 $ 1 , $ 2 , $ 3 , $ 4 , $ 5,可使用$ 0,意即所有域。
1.2保存a w k输出
$ awk ‘{print $0}’ input-files > out-files (#重定向保存输出)
$ awk ‘{print $0}’ input-files | tee out-files (#使用t e e命令,输出到文件的同时输出到屏幕)
1.3 常用的awk命令举例
[root@mypc /]# awk ‘$0 ~ /user/’ /etc/passwd (#如果某域含有user就将该行打印出来)
rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
[root@mypc /]# awk ‘/user/’ /etc/passwd (#同上)
[root@mypc /]# awk -F: ‘{if ($5 ~ /user/) print $0}’ /etc/passwd (#如第五域有user则输出该行)
rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin
[root@mypc /]# ifconfig | awk ‘/inet/{print $2}’ (#从ifconfig的输出中抽取含inet的行并打印第二域)
[root@mypc /]# ifconfig | awk ‘/inet/{print $2}’ | awk -F: ‘{print $2}’ (#在上面的基础上再抽取,这个命令可以让你直接得到本机的ip地址)
Sed的常用命令语法
Sed是一个非交互性文本流编辑器。它编辑文件或标准输入导出的文本拷贝。
1.行的匹配
[root@mypc /]# sed -n ‘2p’ /etc/passwd 打印出第2行
[root@mypc /]# sed -n ‘1,3p’ /etc/passwd 打印出第1到第3行
[root@mypc /]# sed -n ‘$p’ /etc/passwd 打印出最后一行
[root@mypc /]# sed -n ‘/user/’p /etc/passwd 打印出含有user的行
rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
[root@mypc /]# sed -n ‘/\$/’p /etc/passwd 打印出含有$元字符的行,$意为最后一行
2.插入文本和附加文本(插入新行)
[root@mypc /]# sed -n ‘/FTP/p’ /etc/passwd 打印出有FTP的行
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
[root@mypc /]# sed ‘/FTP/ a\ 456′ /etc/passwd 在含有FTP的行后面新插入一行,内容为456
[root@mypc /]# sed ‘/FTP/ i\ 123′ /etc/passwd在含有FTP的行前面新插入一行,内容为123
[root@mypc /]# sed ‘/FTP/ i\ “123″‘ /etc/passwd在含有FTP的行前面新插入一行,内容为”123″
[root@mypc /]# sed ‘5 a\ 123′ /etc/passwd 在第5行后插入一新行,内容为123
[root@mypc /]# sed ‘5 i\ “12345″‘ /etc/passwd 在第5行前插入一新行,内容为”12345″
3.删除文本
[root@mypc /]# sed ‘1d’ /etc/passwd 删除第1行
[root@mypc /]# sed ‘1,3d’ /etc/passwd 删除第1至3行
[root@mypc /]# sed ‘/user/d’ /etc/passwd 删除带有user的行
4. 替换文本,替换命令用替换模式替换指定模式,格式为:
[ a d d r e s s [,address]] s/ pattern-to-find /replacement-pattern/[g p w n]
[root@mypc /]# sed ’s/user/USER/’ /etc/passwd 将第1个user替换成USER,g表明全局替换
[root@mypc /]# sed ’s/user/USER/g’ /etc/passwd 将所有user替换成USER
[root@mypc /]# sed ’s/user/#user/’ /etc/passwd 将第1个user替换成#user,如用于屏蔽作用
[root@mypc /]# sed ’s/user//’ /etc/passwd 将第1个user替换成空
[root@mypc /]# sed ’s/user/&11111111111111/’ /etc/passwd 如果要附加或修改一个很长的字符串,可以使用( &)命令,&命令保存发现模式以便重新调用它,然后把它放在替换字符串里面,这里是把&放前面
[root@mypc /]# sed ’s/user/11111111111111&/’ /etc/passwd 这里是将&放后面
5. 快速一行命令
下面是一些一行命令集。([ ]表示空格,[ ]表示t a b键)
‘s / \ . $ / / g’ 删除以句点结尾行
‘-e /abcd/d’ 删除包含a b c d的行
‘s / [ ] [ ] [ ] * / [ ] / g’ 删除一个以上空格,用一个空格代替
‘s / ^ [ ] [ ] * / / g’ 删除行首空格
‘s / \ . [ ] [ ] * / [ ] / g’ 删除句点后跟两个或更多空格,代之以一个空格
‘/ ^ $ / d’ 删除空行
‘s / ^ . / / g’ 删除第一个字符
‘s /COL \ ( . . . \ ) / / g’ 删除紧跟C O L的后三个字母
‘s / ^ \ / / / g’ 从路径中删除第一个\
‘s / [ ] / [ ] / / g’ 删除所有空格并用t a b键替代
‘S / ^ [ ] / / g’ 删除行首所有t a b键
‘s / [ ] * / / g’ 删除所有t a b键
如果使用s e d对文件进行过滤,最好将问题分成几步,分步执行,且边执行边测试结果。
经验告诉我们,这是执行一个复杂任务的最有效方式。
http://en.wikipedia.org/wiki/Joe_job
2008-06-24 13:22:26 no host name found for IP address 58.248.7.24
2008-06-24 13:22:27 H=(yahoo.com.cn) [58.248.7.24] Warning: Sender rate 4.1 / 1h
2008-06-24 13:22:28 H=(yahoo.com.cn) [58.248.7.24] F=<lkjww11@yahoo.com.cn> rejected RCPT <info@xxxxx.com>: (yahoo.com.cn) [58.248.7.24] is currently not permitted to relay through this server. Perhaps you have not logged into the pop/imap server in the last 30 minutes or do not have SMTP Authentication turned on in your email client.
/etc/localdomains
/etc/init.d -why the timestamp has been changed ? (files under the folder)
Powered by hoder.org