??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久久久精品免费看SSS,天天综合久久一二三区,青青久久精品国产免费看 http://www.shnenglu.com/prayer/在一般中L卓越zh-cnTue, 06 May 2025 21:40:53 GMTTue, 06 May 2025 21:40:53 GMT60DB2 ~冲池调优Bufferpoolshttp://www.shnenglu.com/prayer/archive/2019/06/24/216446.htmlPrayerPrayerMon, 24 Jun 2019 02:09:00 GMThttp://www.shnenglu.com/prayer/archive/2019/06/24/216446.htmlhttp://www.shnenglu.com/prayer/comments/216446.htmlhttp://www.shnenglu.com/prayer/archive/2019/06/24/216446.html#Feedback0http://www.shnenglu.com/prayer/comments/commentRss/216446.htmlhttp://www.shnenglu.com/prayer/services/trackbacks/216446.htmlhttps://blog.csdn.net/liujinwei2005/article/details/8547190

DB2 ~冲池调优Bufferpools


背景知识
~冲池是内存中的一块存储区域,用于临时d和更?a target="_blank" style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; color: #4ea1db; cursor: pointer; font-family: 'Microsoft YaHei', 'SF Pro Display', Roboto, Noto, Arial, 'PingFang SC', sans-serif; word-wrap: break-word;">数据?/span>(包含表行或烦引项Q。缓冲池的用途是Z提高数据库系l的性能。从内存讉K数据要比从磁盘访问数据快得多。因此,数据?a target="_blank" style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; color: #4ea1db; cursor: pointer; font-family: 'Microsoft YaHei', 'SF Pro Display', Roboto, Noto, Arial, 'PingFang SC', sans-serif; word-wrap: break-word;">器需要从盘d或写入磁盘的ơ数少Q性能p好。对一个或多个~冲池进行配|之所以是调优的最重要斚wQ是因ؓq接x据库的应用程序的大多数数据(不包括大对象和长字段数据Q操作都在缓冲池中进行?/div>
~省情况下,应用E序使用~冲?IBMDEFAULTBPQ它是在创徏数据库时创徏的。当 SYSCAT.BUFFERPOOLS 目录表中该缓冲池?NPAGES gؓ -1 ӞDB2 数据库配|参?BUFFPAGE 控制着~冲池的大小。否则会忽略 BUFFPAGE 参数Qƈ且用 NPAGES 参数所指定的页数创建缓冲池?/div>
对于仅用一个缓冲池的应用程序,?NPAGES 更改?-1Q这?BUFFPAGE 可以控制该~冲池的大小。这使得更新和报告缓冲池大小以及其它 DB2 数据库配|参数变得更加方ѝ?/div>
保可以使用数据库配|中?BUFFPAGE 参数来控制缓冲池大小之后Q将该参数设|成合适的倹{根据数据库的大和应用E序的性质该参数讄成一个合理的大|q种做法很安全。通常Q该参数的缺省值非常小Q可能满不了要求。请考虑下列情况Q?/div>
一开始,如果您的机器上有_大的内存Q请?BUFFPAGE 讄?40000 个页Q?60 MBQ,或者等于机器d存的 10%?nbsp;
对于大型 OLTP 数据库,在保持系l稳定的同时为缓冲池留出可能多的内存。一开始,先尝试?1.6 GB 的内存,然后试用更多内存?nbsp;
如何更改该参?/div>
q行下面q个脚本Q以便: 
验证目录?nbsp;
启用数据库配|参?BUFFPAGE 
更新所有数据库?BUFFPAGE 倹{?nbsp;
db2 -v connect to DB_NAME
db2 -v select * from syscat.bufferpools
db2 -v alter bufferpool IBMDEFAULTBP size -1
db2 -v connect reset
db2 -v update db cfg for dbname using BUFFPAGE bigger_value
db2 -v terminate
研究步骤
要确定数据库的缓冲池大小是否?BUFFPAGE 参数所军_Q请q行Q?/div>
db2 -v connect to DB_NAME
db2 -v SELECT * from SYSCAT.BUFFERPOOLS
db2 -v connect reset
db2 -v terminate
查结果。如果每个缓冲池都有一个ؓ“-1”?NPAGES |那么~冲池大是由数据库配置中的 BUFFPAGE 参数控制的?/div>
要确定缓冲池大小是否_大,请在q行应用E序时收集数据库和/或缓冲池的快照。类g下面的脚本ؓ您提供这些所需的信息:
db2 -v update monitor switches using bufferpool on
db2 -v get monitor switches
db2 -v reset monitor all
-- run your application --
db2 -v get snapshot for all databases > snap.out
db2 -v get snapshot for dbm >> snap.out
db2 -v get snapshot for all bufferpools >> snap.out
db2 -v reset monitor all
db2 -v terminate
L保您在断开数据库连接之前发?#8220;db2 -v get snapshot”。当最后一个应用程序与数据库断开q接Ӟ该数据库停止q行Q同时所有快照统计信息将会丢失。要保一直存在数据库处于正常运行状态的q接Q请使用下列Ҏ之一Q?/div>
在收集快照的H口中保持一个单独的q接?nbsp;
使用 DB2 ACTIVATE DATABASE 命o?/div>
在数据库快照或缓冲池快照的快照输ZQ查找下?#8220;logical reads”?#8220;physical reads”Q这样就可以计算出缓冲池命中率,它可以帮助您调优~冲池:
-- Related lines from a sample of bufferpool snapshots --
Buffer pool data logical reads = 702033
Buffer pool data physical reads = 0
Buffer pool data writes = 414
Buffer pool index logical reads = 168255
Buffer pool index physical reads = 0
~冲池命中率表明数据库管理器不需要从盘装入(卌已l在~冲池中Q就能处理页h的时间百分比。缓冲池的命中率高Q用磁?I/O 的频率就低。按如下计算~冲池命中率Q?/div>
(1 - ((buffer pool data physical reads + buffer pool index physical reads) /
(buffer pool data logical reads + pool index logical reads))
) * 100%
q个计算考虑了缓冲池高速缓存的所有页Q烦引和数据Q。理x况下Q该比率应当过 95%Qƈ可能接q?100%。要提高~冲池命中率Q请试下面q些ҎQ?/div>
增加~冲池大?nbsp;
考虑分配多个~冲池,如果可能的话Qؓ每个l常被访问的大表所属的表空间分配一个缓冲池Qؓ一l小表分配一个缓冲池Q然后尝试一下用不同大的~冲池以查看哪种l合会提供最x能?nbsp;
如果已分配的内存不能帮助提高性能Q那么请避免l缓冲池分配q多的内存。应当根据取自测试环境的快照信息来决定缓冲池的大?/div>

~冲池命中率

q个比率说明了ؓ面h提供服务Ӟ数据库管理器不需从磁盘装入页Q即该页已经在缓冲池中)p处理请求的旉癑ֈ比?/p>

计算Q?/p>

BPHR = (1 - ((~冲池数据物理读 + ~冲池烦引物理读) /

(~冲池数据逻辑?+ ~冲池烦引逻辑? ) ) * 100%

索引命中?/p>

q个比率表明了可以在~冲池中扑ֈ的页面能够满的对烦引页的所有读h所占的癑ֈ比?/p>

计算Q?/p>

IHR = (1 - (~冲池烦引物理读 / ~冲池烦引逻辑? ) ) * 100%

数据命中?/p>

q个比率说明了可以在~冲池中扑ֈ的页面能够满的Ҏ据页的所有读h所占的癑ֈ比?/p>

计算Q?/p>

DHR = (1 - (~冲池数据物理读 / ~冲池数据逻辑? ) ) * 100%

l论

~冲池命中率大于 80% 被认为是理想的。对?OLTP pȝ来说Q该值的理想情况是尽可能接近?100% Q烦引命中率更是如此Q?/p>

要提高缓冲池的命中率Q可以增加缓冲池的大,也可以考虑分配多个~冲池,可以为每个经常访问的h自己的表I间的大型表使用一个缓冲池Q也可以Zl小型表使用一个缓冲池?/p>

Prayer 2019-06-24 10:09 发表评论
]]>
UltraEdit讄主题http://www.shnenglu.com/prayer/archive/2019/06/03/216394.htmlPrayerPrayerMon, 03 Jun 2019 10:20:00 GMThttp://www.shnenglu.com/prayer/archive/2019/06/03/216394.htmlhttp://www.shnenglu.com/prayer/comments/216394.htmlhttp://www.shnenglu.com/prayer/archive/2019/06/03/216394.html#Feedback0http://www.shnenglu.com/prayer/comments/commentRss/216394.htmlhttp://www.shnenglu.com/prayer/services/trackbacks/216394.htmlhttps://blog.csdn.net/haifeilang/article/details/54959450
每次下蝲最新的UltraEditQ默认主题是黑色Q很不适应Q想更改主题又常常找不到在哪里,
最新Ultraedit讄主题和老版本不太一P所以网上经验没太大帮助?/div>
记录到博客,以备不时之需Q?/div>
Ultraedit -->布局QLayoutQ?->主题QThemesQ?/div>
      
选择自己喜欢的主题吧Q?/div>
--------------------- 
作者:haifeilang 
来源QCSDN 
原文Qhttps://blog.csdn.net/haifeilang/article/details/54959450 
版权声明Q本文ؓ博主原创文章Q{载请附上博文链接Q?/div>


Prayer 2019-06-03 18:20 发表评论
]]>nm命o中符L型详?/title><link>http://www.shnenglu.com/prayer/archive/2019/04/10/216346.html</link><dc:creator>Prayer</dc:creator><author>Prayer</author><pubDate>Wed, 10 Apr 2019 06:28:00 GMT</pubDate><guid>http://www.shnenglu.com/prayer/archive/2019/04/10/216346.html</guid><wfw:comment>http://www.shnenglu.com/prayer/comments/216346.html</wfw:comment><comments>http://www.shnenglu.com/prayer/archive/2019/04/10/216346.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/prayer/comments/commentRss/216346.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/prayer/services/trackbacks/216346.html</trackback:ping><description><![CDATA[<p style="font-family: 微Y雅黑, 宋体, 黑体, Arial, Helvetica, sans-serif; color: #2f2f2f; font-size: 16px; line-height: 24px; background-color: #ffffff;">nm命o介绍的很多,但大多不介绍其函数符h志的含义?br />最q在调试动态库时常用到Q其中用的最多的用法:<br />nm -A * |grep “aaa” | c++filt  // -A Z昄文gQ?c++filt转换为可读风|好像有个参数也能实现cM功能</p><p style="font-family: 微Y雅黑, 宋体, 黑体, Arial, Helvetica, sans-serif; color: #2f2f2f; font-size: 16px; line-height: 24px; background-color: #ffffff;"><br />其他内容整理如下Q原作者未?:</p><p style="font-family: 微Y雅黑, 宋体, 黑体, Arial, Helvetica, sans-serif; color: #2f2f2f; font-size: 16px; line-height: 24px; background-color: #ffffff;"><span style="font-family: 'Times New Roman'; font-size: 12pt;"><span style="font-family: inherit; background-color: #fffe65;">nm</span></span><span style="font-family: 宋体; font-size: 12pt;">用于列出目标文g的符h单,如果没有指定目标文gQ则默认?#8220;</span><span style="font-family: 'Times New Roman'; font-size: 12pt;">a.out</span><span style="font-family: 宋体; font-size: 12pt;">”?/span><span style="font-family: 'Times New Roman'; font-size: 12pt;"><span style="font-family: inherit; background-color: #fffe65;">nm</span></span><span style="font-family: 宋体; font-size: 12pt;">的格式如下:</span></p><p style="font-family: 微Y雅黑, 宋体, 黑体, Arial, Helvetica, sans-serif; color: #2f2f2f; font-size: 16px; line-height: 24px; background-color: #ffffff;"><span style="font-family: 宋体; font-size: 12pt;"><span style="font-family: inherit; font-size: 9pt;"><span style="font-family: Arial; font-size: small;"><span style="font-family: inherit; background-color: #fffe65;">nm</span> [‘-a’|‘--debug-syms’] [‘-g’|‘--extern-only’]</span></span><br /><span style="font-family: Arial;"><span style="font-family: inherit; font-size: small;"><span style="font-family: inherit;">         [‘-B’] [‘-C’|‘--demangle’[=style]] [‘-D’|‘--dynamic’]</span></span></span><br /><span style="font-family: Arial;"><span style="font-family: inherit; font-size: small;"><span style="font-family: inherit;">         [‘-S’|‘--print-size’] [‘-s’|‘--print-armap’]</span></span></span><br /><span style="font-family: Arial;"><span style="font-family: inherit; font-size: small;"><span style="font-family: inherit;">         [‘-A’|‘-o’|‘--print-file-name’][‘--special-syms’]</span></span></span><br /><span style="font-family: Arial;"><span style="font-family: inherit; font-size: small;"><span style="font-family: inherit;">         [‘-n’|‘-v’|‘--numeric-sort’] [‘-p’|‘--no-sort’]</span></span></span><br /><span style="font-family: Arial;"><span style="font-family: inherit; font-size: small;"><span style="font-family: inherit;">         [‘-r’|‘--reverse-sort’] [‘--size-sort’] [‘-u’|‘--undefined-only’]</span></span></span><br /><span style="font-family: Arial;"><span style="font-family: inherit; font-size: small;"><span style="font-family: inherit;">         [‘-t’ radix|‘--radix=’radix] [‘-P’|‘--portability’]</span></span></span><br /><span style="font-family: Arial;"><span style="font-family: inherit; font-size: small;"><span style="font-family: inherit;">         [‘--target=’bfdname] [‘-f’format|‘--format=’format]</span></span></span><br /><span style="font-family: Arial;"><span style="font-family: inherit; font-size: small;"><span style="font-family: inherit;">         [‘--defined-only’] [‘-l’|‘--line-numbers’] [‘--no-demangle’]</span></span></span><br /><span style="font-family: inherit; font-size: small;"><span style="font-family: Arial;"><span style="font-family: inherit; font-size: 9pt;">       </span></span><span style="font-family: Arial;"> <span style="font-family: inherit; font-size: 9pt;">[‘-V’|‘--version’] [‘-X 32_64’] [‘--help’] [objfile...]</span></span></span><br /><span style="font-family: Arial;"><span style="font-family: inherit; font-size: small;"><span style="font-family: inherit; font-size: 9pt;">  </span></span></span><br /><span style="font-family: inherit; font-size: small;">对于每一个符P<span style="font-family: inherit; background-color: #fffe65;">nm</span>列出其?the symbol value)Q类型(the symbol typeQ和其名?the symbol name)?/span><br /><span style="font-family: inherit; font-size: 12pt;">如下例:</span><br /><span style="font-family: inherit; font-size: 12pt;">  </span><br />     00000024 T cleanup_before_linux<br />     00000018 T cpu_init<br /><span style="font-family: inherit; font-size: 9pt;"><span style="font-family: inherit; font-size: small;">     00000060 T dcache_disable</span></span><br /><span style="font-family: inherit; font-size: 9pt;"><span style="font-family: inherit; font-size: small;">     00000054 T dcache_enable</span></span><br /><span style="font-family: inherit; font-size: 9pt;"><span style="font-family: inherit; font-size: small;">     0000006c T dcache_status</span></span><br /><span style="font-family: inherit; font-size: 9pt;"><span style="font-family: inherit; font-size: small;">     00000000 T do_reset</span></span><br /><span style="font-family: inherit; font-size: 9pt;"><span style="font-family: inherit; font-size: small;">     0000003c T icache_disable</span></span><br /><span style="font-family: inherit; font-size: 9pt;"><span style="font-family: inherit; font-size: small;">     00000030 T icache_enable</span></span><br /><span style="font-family: inherit; font-size: 9pt;"><span style="font-family: inherit; font-size: small;">     00000048 T icache_status</span></span><br /><span style="font-family: inherit; font-size: 9pt;"><span style="font-family: inherit; font-size: small;"> <br />上面的显C是使用<span style="font-family: inherit; background-color: #fffe65;">nm</span> cpu.o的输出,对于cleanup_before_linuxq个W号来说Q?0000024是以16q制昄的其|T为其cdQ而cleanup_before_linux是其名字。可以看出,上面昄?span style="font-family: inherit; color: blue;">cleanup_before_linux</span><span style="font-family: inherit; color: blue;">q个</span><span style="font-family: inherit; color: blue;">symbol</span><span style="font-family: inherit; color: blue;">的值实际上是该函数?/span><span style="font-family: inherit; color: blue;">text section</span><span style="font-family: inherit; color: blue;">中的偏移。但是,每个W号的值的具体含义依其cd而异</span>。当Ӟ对于每个W号的|其类型、其g及它们所属的section是密切相关的?br />下面说明W号cdQ?span style="font-family: inherit; font-size: 12pt;">对于每一个符h_其类型如果是写的,则表明该W号?/span><span style="font-family: inherit; font-size: 12pt;">local</span><span style="font-family: inherit; font-size: 12pt;">的;大写则表明该W号?/span><span style="font-family: inherit; font-size: 12pt;">global(external)</span><span style="font-family: inherit; font-size: 12pt;">的?/span></span></span></span></p><table border="1" cellpadding="0" cellspacing="0" style="color: #2f2f2f; font-family: 微Y雅黑, 宋体, 黑体, Arial, Helvetica, sans-serif; font-size: 16px; line-height: 24px; background-color: #ffffff; border-collapse: collapse; margin-left: 14.4pt;"><tbody><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; width: 36pt; border: 1.5pt double silver;"><strong><span style="font-family: inherit; font-size: 9pt;">W号</span></strong><br /><strong><span style="font-family: inherit; font-size: 9pt;">cd</span></strong></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: 1.5pt 1.5pt 1.5pt medium; border-style: double double double none; width: 378pt; border-top-color: silver; border-right-color: silver;"><strong><span style="font-family: inherit; font-size: 9pt;">说明</span></strong></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">A</span></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">该符L值是l对的,在以后的链接q程中,不允许进行改变。这L<span style="font-family: inherit; color: blue;">W号|常常出现在中断向量表中,例如用符h表示各个中断向量函数在中断向量表中的位置?/span></span></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">B</span></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">该符L值出现在非初始化数据D?/span><span style="font-family: inherit; font-size: 9pt;">(bss)</span><span style="font-family: inherit; font-size: 9pt;">中。例如,<span style="font-family: inherit; color: blue;">在一个文件中定义全局</span></span><span style="font-family: inherit; color: blue; font-size: 9pt;">static int test</span><span style="font-family: inherit; color: blue; font-size: 9pt;">。则该符?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">test</span><span style="font-family: inherit; color: blue; font-size: 9pt;">的类型ؓ</span><span style="font-family: inherit; color: blue; font-size: 9pt;">b</span><span style="font-family: inherit; color: blue; font-size: 9pt;">Q位?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">bss section</span><span style="font-family: inherit; color: blue; font-size: 9pt;">中。其DCW号?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">bss</span><span style="font-family: inherit; color: blue; font-size: 9pt;">D中的偏UR一般而言Q?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">bss</span><span style="font-family: inherit; color: blue; font-size: 9pt;">D分配于</span><span style="font-family: inherit; color: blue; font-size: 9pt;">RAM</span><span style="font-family: inherit; color: blue; font-size: 9pt;">?/span></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">C</span></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">该符号ؓ</span><span style="font-family: inherit; font-size: 9pt;">common</span><span style="font-family: inherit; font-size: 9pt;">?/span><span style="font-family: inherit; font-size: 9pt;">common symbol</span><span style="font-family: inherit; font-size: 9pt;">是未初始话数据段?span style="font-family: inherit; color: blue;">该符h有包含于一个普?/span></span><span style="font-family: inherit; color: blue; font-size: 9pt;">section</span><span style="font-family: inherit; color: blue; font-size: 9pt;">中。只有在链接q程中才q行分配。符LDCW号需要的字节数。例如在一?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">c</span><span style="font-family: inherit; color: blue; font-size: 9pt;">文g中,定义</span><span style="font-family: inherit; color: blue; font-size: 9pt;">int test</span><span style="font-family: inherit; color: blue; font-size: 9pt;">Qƈ且该W号在别的地方会被引用,则该W号cd即ؓ</span><span style="font-family: inherit; color: blue; font-size: 9pt;">C</span><span style="font-family: inherit; color: blue; font-size: 9pt;">。否则其cd?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">B</span><span style="font-family: inherit; color: blue; font-size: 9pt;">?/span></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">D</span></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">该符号位于初始话数据D中?span style="font-family: inherit; color: blue;">一般来_分配?/span></span><span style="font-family: inherit; color: blue; font-size: 9pt;">data section</span><span style="font-family: inherit; color: blue; font-size: 9pt;">中。例如定义全局</span><span style="font-family: inherit; color: blue; font-size: 9pt;">int baud_table[5] = {9600, 19200, 38400, 57600, 115200}</span><span style="font-family: inherit; color: blue; font-size: 9pt;">Q则会分配于初始化数据段?/span><span style="font-family: inherit; font-size: 9pt;">?/span></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">G</span></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">该符号也位于初始化数据段中。主要用?/span><span style="font-family: inherit; font-size: 9pt;">small object</span><span style="font-family: inherit; font-size: 9pt;">提高讉K</span><span style="font-family: inherit; font-size: 9pt;">small data object</span><span style="font-family: inherit; font-size: 9pt;">的一U方式?/span></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">I</span></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">该符h对另一个符L间接引用?/span></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">N</span></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">该符h一?/span><span style="font-family: inherit; font-size: 9pt;">debugging</span><span style="font-family: inherit; font-size: 9pt;">W号?/span></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">R</span></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">该符号位于只L据区?span style="font-family: inherit; color: blue;">例如定义全局</span></span><span style="font-family: inherit; color: blue; font-size: 9pt;">const int test[] = {123, 123};</span><span style="font-family: inherit; color: blue; font-size: 9pt;">?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">test</span><span style="font-family: inherit; color: blue; font-size: 9pt;">是一个只L据区的符受注意在</span><span style="font-family: inherit; color: blue; font-size: 9pt;">cygwin</span><span style="font-family: inherit; color: blue; font-size: 9pt;">下如果?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">gcc</span><span style="font-family: inherit; color: blue; font-size: 9pt;">直接~译?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">MZ</span><span style="font-family: inherit; color: blue; font-size: 9pt;">格式Ӟ源文件中?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">test</span><span style="font-family: inherit; color: blue; font-size: 9pt;">对应</span><span style="font-family: inherit; color: blue; font-size: 9pt;">_test</span><span style="font-family: inherit; color: blue; font-size: 9pt;">Qƈ且其W号cd?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">D</span><span style="font-family: inherit; color: blue; font-size: 9pt;">Q即初始化数据段中。但是如果?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">m6812-elf-gcc</span><span style="font-family: inherit; color: blue; font-size: 9pt;">q样的交叉编译工P源文件中?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">test</span><span style="font-family: inherit; color: blue; font-size: 9pt;">对应目标文g?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">test,</span><span style="font-family: inherit; color: blue; font-size: 9pt;">x有添加下划线Qƈ且其W号cd?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">R</span><span style="font-family: inherit; color: blue; font-size: 9pt;">。一般而言Q位?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">rodata section</span><span style="font-family: inherit; color: blue; font-size: 9pt;">。值得注意的是Q如果在一个函C定义</span><span style="font-family: inherit; color: blue; font-size: 9pt;">const char *test = “abc”, const char test_int = 3</span><span style="font-family: inherit; color: blue; font-size: 9pt;">。?/span><span style="font-family: inherit; color: blue; font-size: 9pt;"><span style="font-family: inherit; background-color: #fffe65;">nm</span></span><span style="font-family: inherit; color: blue; font-size: 9pt;">都不会得到符号信息,但是字符?#8220;</span><span style="font-family: inherit; color: blue; font-size: 9pt;">abc</span><span style="font-family: inherit; color: blue; font-size: 9pt;">”分配于只d储器中,</span><span style="font-family: inherit; color: blue; font-size: 9pt;">test</span><span style="font-family: inherit; color: blue; font-size: 9pt;">?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">rodata section</span><span style="font-family: inherit; color: blue; font-size: 9pt;">中,大小?/span><span style="font-family: inherit; color: blue; font-size: 9pt;">4</span><span style="font-family: inherit; color: blue; font-size: 9pt;">?/span></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">S</span></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">W号位于非初始化数据区,用于</span><span style="font-family: inherit; font-size: 9pt;">small object</span><span style="font-family: inherit; font-size: 9pt;">?/span></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">T</span></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">该符号位于代码区</span><span style="font-family: inherit; font-size: 9pt;">text section</span><span style="font-family: inherit; font-size: 9pt;">?/span></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">U</span></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">该符号在当前文g中是未定义的Q即该符L定义在别的文件中?span style="font-family: inherit; color: blue;">例如Q当前文件调用另一个文件中定义的函敎ͼ在这个被调用的函数在当前是未定义的Q但是在定义它的文g中类型是</span></span><span style="font-family: inherit; color: blue; font-size: 9pt;">T</span><span style="font-family: inherit; color: blue; font-size: 9pt;">。但是对于全局变量来说Q在定义它的文g中,其符L型ؓ</span><span style="font-family: inherit; color: blue; font-size: 9pt;">C</span><span style="font-family: inherit; color: blue; font-size: 9pt;">Q在使用它的文g中,其类型ؓ</span><span style="font-family: inherit; color: blue; font-size: 9pt;">U</span><span style="font-family: inherit; color: blue; font-size: 9pt;">?/span></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">V</span></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">该符h一?/span><span style="font-family: inherit; font-size: 9pt;">weak object</span><span style="font-family: inherit; font-size: 9pt;">?/span></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">W</span></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">The symbol is a weak symbol that has not been specifically tagged as a weak object symbol.</span></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">-</span></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">该符h</span><span style="font-family: inherit; font-size: 9pt;">a.out</span><span style="font-family: inherit; font-size: 9pt;">格式文g中的</span><span style="font-family: inherit; font-size: 9pt;">stabs symbol</span><span style="font-family: inherit; font-size: 9pt;">?/span></td></tr><tr><td valign="top" width="48" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt; border-style: none double double; border-left-color: silver; width: 36pt; border-right-color: silver;"></td><td valign="top" width="504" style="margin: 0px; padding: 0cm 5.4pt; border-bottom-color: silver; border-width: medium 1.5pt 1.5pt medium; border-style: none double double none; width: 378pt; border-right-color: silver;"><span style="font-family: inherit; font-size: 9pt;">该符L型没有定?/span></td></tr></tbody></table><img src ="http://www.shnenglu.com/prayer/aggbug/216346.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/prayer/" target="_blank">Prayer</a> 2019-04-10 14:28 <a href="http://www.shnenglu.com/prayer/archive/2019/04/10/216346.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>sed -i命o详解http://www.shnenglu.com/prayer/archive/2019/04/04/216337.htmlPrayerPrayerThu, 04 Apr 2019 09:49:00 GMThttp://www.shnenglu.com/prayer/archive/2019/04/04/216337.htmlhttp://www.shnenglu.com/prayer/comments/216337.htmlhttp://www.shnenglu.com/prayer/archive/2019/04/04/216337.html#Feedback0http://www.shnenglu.com/prayer/comments/commentRss/216337.htmlhttp://www.shnenglu.com/prayer/services/trackbacks/216337.htmlhttps://www.cnblogs.com/ev-zhk/p/4277023.html
[root@www ~]# sed [-nefr] [动作] 选项与参敎ͼ -n Q用安?silent)模式。在一?sed 的用法中Q所有来?STDIN 的数据一般都会被列出到终端上。但如果加上 -n 参数后,则只有经qsed Ҏ处理的那一?或者动?才会被列出来?-e Q直接在命o列模式上q行 sed 的动作编辑; -f Q直接将 sed 的动作写在一个文件内Q?-f filename 则可以运?filename 内的 sed 动作Q?-r Q?span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">sed 的动作支持的是g伸型正规表示法的语法?默认是基正规表示法语? -i Q直接修改读取的文g内容Q而不是输出到l端? 动作说明Q?[n1[,n2]]function n1, n2 Q不见得会存在,一般代表『选择q行动作的行数』,举例来说Q如果我的动作是需要在 10 ?20 行之间进行的Q则?10,20[动作行ؓ] ? functionQ?a Q新增, a 的后面可以接字串Q而这些字串会在新的一行出?目前的下一??c Q取代, c 的后面可以接字串Q这些字串可以取?n1,n2 之间的行Q?d Q删除,因ؓ是删除啊Q所?d 后面通常不接M咚咚Q?i Q插入, i 的后面可以接字串Q而这些字串会在新的一行出?目前的上一?Q?p Q列华ͼ亦即某个选择的数据印出。通常 p 会与参数 sed -n 一赯行~ s Q取代,可以直接q行取代的工作哩Q通常q个 s 的动作可以搭配正规表C法Q例?1,20s/old/new/g 是啦!
复制代码


sed -i 是直接Ҏ本文件进行操作的

sed -i 's/原字W串/新字W串/' /home/1.txt sed -i 's/原字W串/新字W串/g' /home/1.txt


q两条命令的区别是Q看CZ?/p>

q是1.txt的内?/p>

#cat 1.txt d ddd #ff

再看执行q两条命令的区别?/p>

复制代码
sed -i 's/d/7523/' /home/1.txt 执行l果 7523 7523dd #ff  sed -i 's/d/7523/g' /home/1.txt 执行l果 7523 752375237523 #ff
复制代码

 

L “行首” ?#8220;@”的首字母@

sed -i 's/^@//' file

 

特定字符串的行前插入新行

sed -i '/特定字符?i 新行字符?/span>' file

 

特定字符串的行后插入新行

sed -i '/特定字符?a 新行字符?/span>' file

 

特定字符串的删除

sed -i '/字符?d' file

 



Prayer 2019-04-04 17:49 发表评论
]]>sed中用变量替换以及执行外部命?/title><link>http://www.shnenglu.com/prayer/archive/2019/04/04/216336.html</link><dc:creator>Prayer</dc:creator><author>Prayer</author><pubDate>Thu, 04 Apr 2019 09:46:00 GMT</pubDate><guid>http://www.shnenglu.com/prayer/archive/2019/04/04/216336.html</guid><wfw:comment>http://www.shnenglu.com/prayer/comments/216336.html</wfw:comment><comments>http://www.shnenglu.com/prayer/archive/2019/04/04/216336.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/prayer/comments/commentRss/216336.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/prayer/services/trackbacks/216336.html</trackback:ping><description><![CDATA[<div>https://blog.csdn.net/halazi100/article/details/41722021<br /><br /><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-family: 'Microsoft YaHei', 'SF Pro Display', Roboto, Noto, Arial, 'PingFang SC', sans-serif; font-size: 16px; color: #4f4f4f; line-height: 26px; overflow-x: auto; word-wrap: break-word; background-color: #ffffff;">在用sedҎ志或者其它文本进行parse的过E当中,有时候我们需要引用外部变量的|<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />或者获取一个shell命o执行的结果,以便辑ֈ更加可观的输出结果。这里介l如何做到?br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />sed中用变量替?br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />1.sed命o使用双引L情况下,使用$var直接引用<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />$ echo|sed "s/^/$RANDOM.rmvb_/g"<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> 29328.rmvb_</p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-family: 'Microsoft YaHei', 'SF Pro Display', Roboto, Noto, Arial, 'PingFang SC', sans-serif; font-size: 16px; color: #4f4f4f; line-height: 26px; overflow-x: auto; word-wrap: break-word; background-color: #ffffff;">如果替换的变量内容中含有/W号则会提示如下错误Q如<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />查找当前目录下的目录文gq将相对路径替换为绝对\?br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />find . -type f | sed -n "s/\./$PWD/p"<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />sed: -e expression #1, char 19: unknown option to `s'<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />从语法上看,没有M问题Q但׃变量中包含有“/”作ؓ分隔W,q会和sed的替换操作的分隔W?#8220;/”引vhQ所以,只要不?#8220;/”做分隔符可以解册个问题,如果使用“%”而不?#8220;/”来作为sed的替换操作的分隔W,׃会出错。其实???作ؓ分隔W也是可以的Q只要不会与替换中有相同的而且不是元字W的ҎW号都是可以的;使用时可以根据情늁z选择?br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />find . -type f | sed -n "s%\.%$PWD%p"<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />find . -type f | sed -n "s#\.#$PWD#p"</p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-family: 'Microsoft YaHei', 'SF Pro Display', Roboto, Noto, Arial, 'PingFang SC', sans-serif; font-size: 16px; color: #4f4f4f; line-height: 26px; overflow-x: auto; word-wrap: break-word; background-color: #ffffff;"># 上面例子引用了一个环境变?RANDOM的?br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />2.sed命o使用单引L情况下,使用'"$var"'引用<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />cMQ我们可以看?br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />$ echo|sed 's/^/'"$RANDOM"'.rmvb_/g'<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> 31338.rmvb_<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />sed中执行外部命?br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />1.sed命o使用单引L情况下?`shell command`'或?$(shell command)'引用命o执行的结?br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />q是以上面案例分析,例子如下<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />$ echo|sed 's/^/'`echo $RANDOM`'.rmvb_/g'<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> 8063.rmvb_<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> </p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-family: 'Microsoft YaHei', 'SF Pro Display', Roboto, Noto, Arial, 'PingFang SC', sans-serif; font-size: 16px; color: #4f4f4f; line-height: 26px; overflow-x: auto; word-wrap: break-word; background-color: #ffffff;"># 上面的例子用了旧式的命令替换,也可以采用新式的命o替换ҎQ如?br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />$ echo|sed 's/^/'$(echo $RANDOM)'.rmvb_/g'<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> 18554.rmvb_<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> </p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-family: 'Microsoft YaHei', 'SF Pro Display', Roboto, Noto, Arial, 'PingFang SC', sans-serif; font-size: 16px; color: #4f4f4f; line-height: 26px; overflow-x: auto; word-wrap: break-word; background-color: #ffffff;"># 下面例子取用当前日期作ؓl果的一部分Q如?br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />$ echo|sed 's/^/'$(date +"%Y%m%d")'.rmvb_/g'<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> 20120108.rmvb_<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> </p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-family: 'Microsoft YaHei', 'SF Pro Display', Roboto, Noto, Arial, 'PingFang SC', sans-serif; font-size: 16px; color: #4f4f4f; line-height: 26px; overflow-x: auto; word-wrap: break-word; background-color: #ffffff;">2.sed命o使用双引L情况下直接`shell command`或?(shell command)引用命o执行的结?br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> </p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-family: 'Microsoft YaHei', 'SF Pro Display', Roboto, Noto, Arial, 'PingFang SC', sans-serif; font-size: 16px; color: #4f4f4f; line-height: 26px; overflow-x: auto; word-wrap: break-word; background-color: #ffffff;">cM的,双引L情况Q如?br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />$ echo|sed "s/^/$(date +"%Y%m%d").rmvb_/g"<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> 20120108.rmvb_<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> </p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-family: 'Microsoft YaHei', 'SF Pro Display', Roboto, Noto, Arial, 'PingFang SC', sans-serif; font-size: 16px; color: #4f4f4f; line-height: 26px; overflow-x: auto; word-wrap: break-word; background-color: #ffffff;"># 使用环境变量$RANDOM以及旧式命o替换的例?br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />$ echo|sed "s/^/`echo $RANDOM`.rmvb_/g"<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> 4988.rmvb_<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />ȝ<br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" /> <br style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; word-wrap: break-word;" />在sed语句里面Q变量替换或者执行shell命oQ双引号比单引号绕一些弯?/p></div><img src ="http://www.shnenglu.com/prayer/aggbug/216336.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/prayer/" target="_blank">Prayer</a> 2019-04-04 17:46 <a href="http://www.shnenglu.com/prayer/archive/2019/04/04/216336.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux 比较两个文g夹不?(diff命o, md5列表)http://www.shnenglu.com/prayer/archive/2019/04/04/216335.htmlPrayerPrayerThu, 04 Apr 2019 09:46:00 GMThttp://www.shnenglu.com/prayer/archive/2019/04/04/216335.htmlhttp://www.shnenglu.com/prayer/comments/216335.htmlhttp://www.shnenglu.com/prayer/archive/2019/04/04/216335.html#Feedback0http://www.shnenglu.com/prayer/comments/commentRss/216335.htmlhttp://www.shnenglu.com/prayer/services/trackbacks/216335.html比较文g夹diffQ可以直接用diff命o

[root@~]# diff -urNa dir1 dir2
  -a Treat all files as text and compare them line-by-line, even if they do not seem to be text.
  -N, --new-file
    In directory comparison, if a file is found in only one directory, treat it as present but empty in the other directory.
  -r When comparing directories, recursively compare any subdirectories found.

  -u Use the unified output format.

 

比较文g夹diffQ也可以比较文gMD5列表。下面命令可以获取文件夹中文件md5列表

find /home/ -type f -not \( -name '.*' \) -exec md5sum {} \;

说明Q?1) /home/文g目录

     (2) -type f 文gcd为普通文?/p>

     (3) -not \( -name '.*' \)  qo掉隐藏文件。可以过滤掉不需要考虑的文?/p>

         (4) -exec md5sum {} \;  Ҏ个文件执行md5sum命o 

 

 用tar命o压羃后,比较文g的MD5是不行的。tar压羃会带上文件的旉



Prayer 2019-04-04 17:46 发表评论
]]>
SHELL 在指定行的前/后插入指定内?/title><link>http://www.shnenglu.com/prayer/archive/2019/04/04/216334.html</link><dc:creator>Prayer</dc:creator><author>Prayer</author><pubDate>Thu, 04 Apr 2019 09:13:00 GMT</pubDate><guid>http://www.shnenglu.com/prayer/archive/2019/04/04/216334.html</guid><wfw:comment>http://www.shnenglu.com/prayer/comments/216334.html</wfw:comment><comments>http://www.shnenglu.com/prayer/archive/2019/04/04/216334.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/prayer/comments/commentRss/216334.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/prayer/services/trackbacks/216334.html</trackback:ping><description><![CDATA[<div>https://www.jianshu.com/p/66f79ad53406<br /><br /><h3>如果知道行号可以用下面的Ҏ</h3><pre bash"="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 15px; margin-top: 0px; margin-bottom: 20px; line-height: 1.42857; word-wrap: normal; color: #abb2bf; background-color: #282c34; border: 1px solid #cccccc; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; word-break: break-word !important;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; color: inherit; background-color: transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; padding: 0px; border: none; vertical-align: middle;">sed -i <span style="box-sizing: border-box; color: #98c379;">'88 r b.file'</span> a.file <span style="box-sizing: border-box; color: #929292;">#在a.txt的第88行插入文件b.txt</span> awk <span style="box-sizing: border-box; color: #98c379;">'1;NR==88{system("cat b.file")}'</span> a.file > a.file </code></pre><h3>如果不知道行P可以用正則匹?/h3><pre bash"="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 15px; margin-top: 0px; margin-bottom: 20px; line-height: 1.42857; word-wrap: normal; color: #abb2bf; background-color: #282c34; border: 1px solid #cccccc; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; word-break: break-word !important;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; color: inherit; background-color: transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; padding: 0px; border: none; vertical-align: middle;">sed -i <span style="box-sizing: border-box; color: #98c379;">'/regex/ r b.txt'</span> a.txt <span style="box-sizing: border-box; color: #929292;"># regex是正则表辑ּ</span> awk <span style="box-sizing: border-box; color: #98c379;">'/target/{system("cat b.file")}'</span> a.file > c.file </code></pre><h3>sed的話如果不改变源文gQ可以去?i开养I修改会输出到STDOUT</h3><p style="box-sizing: border-box; margin: 0px 0px 25px; color: #2f2f2f; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27px; background-color: #ffffff; word-break: break-word !important;">原文Ӟ</p><pre ruby"="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 15px; margin-top: 0px; margin-bottom: 20px; line-height: 1.42857; word-wrap: normal; color: #abb2bf; background-color: #282c34; border: 1px solid #cccccc; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; word-break: break-word !important;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; color: inherit; background-color: transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; padding: 0px; border: none; vertical-align: middle;">[root@xiaowu shell]<span style="box-sizing: border-box; color: #929292;"># cat -n file </span> <span style="box-sizing: border-box; color: #d19a66;">1</span> aaaa <span style="box-sizing: border-box; color: #d19a66;">2</span> bbbb <span style="box-sizing: border-box; color: #d19a66;">3</span> cccc <span style="box-sizing: border-box; color: #d19a66;">4</span> dddd </code></pre><p style="box-sizing: border-box; margin: 0px 0px 25px; color: #2f2f2f; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27px; background-color: #ffffff; word-break: break-word !important;">现在要在W二行即“bbbb”行的下面d一行,内容?#8220;xiaowu”</p><pre ruby"="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 15px; margin-top: 0px; margin-bottom: 20px; line-height: 1.42857; word-wrap: normal; color: #abb2bf; background-color: #282c34; border: 1px solid #cccccc; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; word-break: break-word !important;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; color: inherit; background-color: transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; padding: 0px; border: none; vertical-align: middle;">[root@xiaowu shell]<span style="box-sizing: border-box; color: #929292;"># sed '/bbbb/a\xiaowu' file </span> aaaa bbbb xiaowu cccc dddd </code></pre><p style="box-sizing: border-box; margin: 0px 0px 25px; color: #2f2f2f; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27px; background-color: #ffffff; word-break: break-word !important;">如果要加两行“xiaowu”可以用一下语句,注意?#8220;\n”换行</p><pre ruby"="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 15px; margin-top: 0px; margin-bottom: 20px; line-height: 1.42857; word-wrap: normal; color: #abb2bf; background-color: #282c34; border: 1px solid #cccccc; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; word-break: break-word !important;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; color: inherit; background-color: transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; padding: 0px; border: none; vertical-align: middle;">[root@xiaowu shell]<span style="box-sizing: border-box; color: #929292;"># sed '/bbbb/a\xiaowu\nxiaowu' file </span> aaaa bbbb xiaowu xiaowu cccc dddd </code></pre><p style="box-sizing: border-box; margin: 0px 0px 25px; color: #2f2f2f; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27px; background-color: #ffffff; word-break: break-word !important;">如果要在W二行即“bbbb”行的上添加一行,内容?#8220;xiaowu”Q可以把参数“a”换成“i”</p><pre ruby"="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 15px; margin-top: 0px; margin-bottom: 20px; line-height: 1.42857; word-wrap: normal; color: #abb2bf; background-color: #282c34; border: 1px solid #cccccc; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; word-break: break-word !important;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; color: inherit; background-color: transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; padding: 0px; border: none; vertical-align: middle;">[root@xiaowu shell]<span style="box-sizing: border-box; color: #929292;"># sed '/b/i\xiaowu' file </span> aaaa xiaowu bbbb cccc dddd </code></pre><p style="box-sizing: border-box; margin: 0px 0px 25px; color: #2f2f2f; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27px; background-color: #ffffff; word-break: break-word !important;">以上文g中只有一行匹配,如果文g中有两行或者多行匹配,l果有是如何呢?</p><pre ruby"="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 15px; margin-top: 0px; margin-bottom: 20px; line-height: 1.42857; word-wrap: normal; color: #abb2bf; background-color: #282c34; border: 1px solid #cccccc; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; word-break: break-word !important;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; color: inherit; background-color: transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; padding: 0px; border: none; vertical-align: middle;">[root@xiaowu shell]<span style="box-sizing: border-box; color: #929292;"># cat -n file </span> <span style="box-sizing: border-box; color: #d19a66;">1</span> aaaa <span style="box-sizing: border-box; color: #d19a66;">2</span> bbbb <span style="box-sizing: border-box; color: #d19a66;">3</span> cccc <span style="box-sizing: border-box; color: #d19a66;">4</span> bbbb <span style="box-sizing: border-box; color: #d19a66;">5</span> dddd </code></pre><pre ruby"="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 15px; margin-top: 0px; margin-bottom: 20px; line-height: 1.42857; word-wrap: normal; color: #abb2bf; background-color: #282c34; border: 1px solid #cccccc; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; word-break: break-word !important;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; color: inherit; background-color: transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; padding: 0px; border: none; vertical-align: middle;">[root@xiaowu shell]<span style="box-sizing: border-box; color: #929292;"># sed '/bbbb/a\xiaowu' file </span> aaaa bbbb xiaowu cccc bbbb xiaowu dddd </code></pre><p style="box-sizing: border-box; margin: 0px 0px 25px; color: #2f2f2f; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27px; background-color: #ffffff; word-break: break-word !important;">q果可知,每个匚w行的下一行都会被d“xiaowu”</p><p style="box-sizing: border-box; margin: 0px 0px 25px; color: #2f2f2f; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27px; background-color: #ffffff; word-break: break-word !important;">那么如果指向在第二个“bbbb”的下一行添加内?#8220;xiaowu”Q该如何操作呢?<br style="box-sizing: border-box;" />可以考虑先获取第二个“bbbb”行的行号Q然后根据行号在此行的下一行添?#8220;xiaowu”</p><p style="box-sizing: border-box; margin: 0px 0px 25px; color: #2f2f2f; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27px; background-color: #ffffff; word-break: break-word !important;">获取W二?#8220;bbbb”行的行号的方法:<br style="box-sizing: border-box;" />Ҏ一Q?/p><pre objectivec"="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 15px; margin-top: 0px; margin-bottom: 20px; line-height: 1.42857; word-wrap: normal; color: #abb2bf; background-color: #282c34; border: 1px solid #cccccc; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; word-break: break-word !important;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; color: inherit; background-color: transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; padding: 0px; border: none; vertical-align: middle;">[root@xiaowu shell]<span style="box-sizing: border-box; color: #61aeee;"># cat -n file |grep b |awk '{print $1}'|sed -n <span style="box-sizing: border-box; color: #98c379;">"2"</span>p</span> <span style="box-sizing: border-box; color: #d19a66;">4</span> </code></pre><p style="box-sizing: border-box; margin: 0px 0px 25px; color: #2f2f2f; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27px; background-color: #ffffff; word-break: break-word !important;">Ҏ二:</p><pre objectivec"="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 15px; margin-top: 0px; margin-bottom: 20px; line-height: 1.42857; word-wrap: normal; color: #abb2bf; background-color: #282c34; border: 1px solid #cccccc; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; word-break: break-word !important;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; color: inherit; background-color: transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; padding: 0px; border: none; vertical-align: middle;">[root@xiaowu shell]<span style="box-sizing: border-box; color: #61aeee;"># sed -n '/bbbb/=' file |sed -n <span style="box-sizing: border-box; color: #98c379;">"2"</span>p</span> <span style="box-sizing: border-box; color: #d19a66;">4</span> </code></pre><p style="box-sizing: border-box; margin: 0px 0px 25px; color: #2f2f2f; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27px; background-color: #ffffff; word-break: break-word !important;">q果可知第二个“bbbb”行的行号?Q然后再在第四行的前或后d相应的内?</p><pre ruby"="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 15px; margin-top: 0px; margin-bottom: 20px; line-height: 1.42857; word-wrap: normal; color: #abb2bf; background-color: #282c34; border: 1px solid #cccccc; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; word-break: break-word !important;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; color: inherit; background-color: transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; padding: 0px; border: none; vertical-align: middle;">[root@xiaowu shell]<span style="box-sizing: border-box; color: #929292;"># sed -e '4a\xiaowu' file </span> aaaa bbbb cccc bbbb xiaowu dddd </code></pre><pre ruby"="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 15px; margin-top: 0px; margin-bottom: 20px; line-height: 1.42857; word-wrap: normal; color: #abb2bf; background-color: #282c34; border: 1px solid #cccccc; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; word-break: break-word !important;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; color: inherit; background-color: transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; padding: 0px; border: none; vertical-align: middle;">[root@xiaowu shell]<span style="box-sizing: border-box; color: #929292;"># sed -e '4a\xiaowu\nxiaowu' file </span> aaaa bbbb cccc bbbb xiaowu xiaowu dddd </code></pre><p style="box-sizing: border-box; margin: 0px 0px 25px; color: #2f2f2f; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27px; background-color: #ffffff; word-break: break-word !important;">向指定行的末添加指定内容,比如?#8220;ccccc”行的行尾介绍“ eeeee”</p><pre ruby"="" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 15px; margin-top: 0px; margin-bottom: 20px; line-height: 1.42857; word-wrap: normal; color: #abb2bf; background-color: #282c34; border: 1px solid #cccccc; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; word-break: break-word !important;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; color: inherit; background-color: transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; padding: 0px; border: none; vertical-align: middle;">[root@xiaowu shell]<span style="box-sizing: border-box; color: #929292;"># cat file</span> aaaaa bbbbb ccccc ddddd [root@xiaowu shell]<span style="box-sizing: border-box; color: #929292;"># sed 's/cc.*/& eeeee/g' file</span> aaaaa bbbbb ccccc eeeee ddddd </code></pre><p style="box-sizing: border-box; margin: 0px 0px 25px; color: #2f2f2f; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27px; background-color: #ffffff; word-break: break-word !important;"><a target="_blank" rel="nofollow" style="box-sizing: border-box; background-color: transparent; color: #3194d0; text-decoration: none; cursor: pointer;">原文链接</a></p></div><img src ="http://www.shnenglu.com/prayer/aggbug/216334.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/prayer/" target="_blank">Prayer</a> 2019-04-04 17:13 <a href="http://www.shnenglu.com/prayer/archive/2019/04/04/216334.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux下提C?usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found 解决办法http://www.shnenglu.com/prayer/archive/2019/04/04/216333.htmlPrayerPrayerThu, 04 Apr 2019 02:15:00 GMThttp://www.shnenglu.com/prayer/archive/2019/04/04/216333.htmlhttp://www.shnenglu.com/prayer/comments/216333.htmlhttp://www.shnenglu.com/prayer/archive/2019/04/04/216333.html#Feedback0http://www.shnenglu.com/prayer/comments/commentRss/216333.htmlhttp://www.shnenglu.com/prayer/services/trackbacks/216333.html在rhel6.6上安装qt后,q行qtcreator提示 “核心载入p|: /opt/Qt5.3.2/Tools/QtCreator/lib/qtcreator/plugins/libCore.so: 无法加蝲?opt/Qt5.3.2/Tools/QtCreator/lib/qtcreator/plugins/libCore.soQ?/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /opt/Qt5.3.2/Tools/QtCreator/lib/qtcreator/plugins/libCore.so))

在网上查找资料后Q解x法如?em id="__mceDel" style="margin: 0px; padding: 0px; line-height: 1.5;">?/em>

 

1.查看gcc版本中包含哪些库?/p>

strings /usr/lib64/libstdc++.so.6 | grep GLIBC

GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.4
GLIBC_2.3.2
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  可以看出不包含GLIBCXX_3.4.14

2.从网上下载高版本的libstdc++.so.6.0.13以上的版本,比如libstdc++.so.6.0.17?/p>

3.把libstdc++.so.6.0.17拯?usr/lib64目录下?/p>

  cp libstdc++.so.6.0.17 /usr/lib64/

4.删除libstdc++.so.6W号q接?/p>

  rm libstdc++.so.6

5.新徏里符可接?/p>

  ln -s libstdc++.so.6.0.17 libstdc++.so.6

6.再次查看没有问题了?/p>

 

libstdc++.so.6.0.17下蝲地址



Prayer 2019-04-04 10:15 发表评论
]]>
lib lib32 lib64{lib文g夹的说明http://www.shnenglu.com/prayer/archive/2019/04/04/216332.htmlPrayerPrayerThu, 04 Apr 2019 02:14:00 GMThttp://www.shnenglu.com/prayer/archive/2019/04/04/216332.htmlhttp://www.shnenglu.com/prayer/comments/216332.htmlhttp://www.shnenglu.com/prayer/archive/2019/04/04/216332.html#Feedback0http://www.shnenglu.com/prayer/comments/commentRss/216332.htmlhttp://www.shnenglu.com/prayer/services/trackbacks/216332.html
  • /lib 
    最基本的共享库和内核模块?nbsp;
    目的 -> 存放用于启动pȝ和执行root文gpȝ的命令的?bin /sbin的二q制文g的共享库Q或者存?2位,或?4?file命o查看)?/li>
  • /lib?/usr/lib?usr/local/lib 
    目的 -> 是Z区分32位和64位而设|的目录。这U情况下/lib有可能是其符号链接?/li>
  • /usr/lib?usr/local/lib 
    E序和安装包的库路径?nbsp;
    说明 -> 不依赖特定架构的库应该放?usr/share中而不是这里。应用程序可以自己创Z个单独的子目录ƈ把自q库放在其中?/p>

  • ȝ 
    一般情况下Q?nbsp;
    pȝ自己会匹配应用程序与其应该调用的位数的库?nbsp;
    如果是用?bin /sbin的库Q放|到/lib*之中?nbsp;
    如果是用于用L序或安装包的Q放|到/usr/lib*?usr/local/lib*之中?nbsp;
    如果某个库只是特别的用了某个专用E序Q而这个程序但q不打算直接被用h者root调用Q应攄?usr/libexec中?/p>

  • http://unix.stackexchange.com/questions/74646/difference-between-lib-lib32-lib64-libx32-and-libexec



    Prayer 2019-04-04 10:14 发表评论
    ]]>
    LinuxE序分析工具介绍—ldd,nmhttp://www.shnenglu.com/prayer/archive/2019/04/03/216328.htmlPrayerPrayerWed, 03 Apr 2019 07:56:00 GMThttp://www.shnenglu.com/prayer/archive/2019/04/03/216328.htmlhttp://www.shnenglu.com/prayer/comments/216328.htmlhttp://www.shnenglu.com/prayer/archive/2019/04/03/216328.html#Feedback0http://www.shnenglu.com/prayer/comments/commentRss/216328.htmlhttp://www.shnenglu.com/prayer/services/trackbacks/216328.html

    本文要介l的ldd和nm是linux下,两个用来分析E序很实用的工具。ldd是用来分析程序运行时需要依赖的动态库的工Pnm是用来查看指定程序中的符可相关内容的工兗下面通过例子Q分别来介绍一下这两个工具Q?/p>

    1. ldd, 先看下面的例? 用ldd查看csE序所依赖的动态库Q?/p>

    1. $ ldd cs  
    2. linux-gate.so.1 =>  (0xffffe000)  
    3. libz.so.1 => /lib/libz.so.1 (0xb7f8c000)  
    4. libpthread.so.0 => /lib/libpthread.so.0 (0xb7f75000)  
    5. libcrypto.so.0.9.8 => /usr/lib/libcrypto.so.0.9.8 (0xb7e4d000)  
    6. libpcre.so.0 => /usr/lib/libpcre.so.0 (0xb7e21000)  
    7. libstdc++.so.6 => /usr/local/gcc4.5.1/lib/libstdc++.so.6 (0xb7d40000)  
    8. libm.so.6 => /lib/libm.so.6 (0xb7d18000)  
    9. libgcc_s.so.1 => /usr/local/gcc4.5.1/lib/libgcc_s.so.1 (0xb7cfd000)  
    10. libc.so.6 => /lib/libc.so.6 (0xb7bbc000)  
    11. /lib/ld-linux.so.2 (0xb7fab000)  
    12. libdl.so.2 => /lib/libdl.so.2 (0xb7bb7000)  

    在上面的例子中,ldd的结果可以分Z列来看:

    •W一列:E序需要依赖什么库
    •W二? pȝ提供的与E序需要的库所对应的库
    •W三列:库加载的开始地址
    通过上面的信息,我们可以得到以下几个信息Q?/p>

    •Q?Q?通过ҎW一列和W二列,我们可以分析E序需要依赖的库和pȝ实际提供的,是否相匹?br style="font-size: 0.95em;" />•Q?Q?通过观察W三列,我们可以知道在当前的库中的符号在对应的进E的地址I间中的开始位|?br style="font-size: 0.95em;" />2. nm, 通过下面的例子,我们来介lnm工具Q?/p>

    先看一下这个简单的E序Q?/p>

    1. #include "iostream"   
    2.    
    3. using namespace std;  
    4.    
    5. class Test  
    6. {  
    7. public:  
    8.     void Hello()  
    9.     {  
    10.         cout < < "Hello world!" << endl;  
    11.     }  
    12. };  
    13.    
    14. int main()  
    15. {  
    16.     Test test;  
    17.     test.Hello();  
    18. }  

    接下来,我们~译该程序,然后看nm的结果:

    1. $ g++ test.cc -o test  
    2. c$ nm test  
    3. 08049f10 d _DYNAMIC  
    4. 08049ff4 d _GLOBAL_OFFSET_TABLE_  
    5. 080486f0 t _GLOBAL__I_main  
    6. 080487fc R _IO_stdin_used  
    7.          w _Jv_RegisterClasses  
    8. 080486b0 t _Z41__static_initialization_and_destruction_0ii  
    9. 0804870c W _ZN4Test5HelloEv  
    10.          U _ZNSolsEPFRSoS_E@@GLIBCXX_3.4  
    11.          U _ZNSt8ios_base4InitC1Ev@@GLIBCXX_3.4  
    12.          U _ZNSt8ios_base4InitD1Ev@@GLIBCXX_3.4  
    13. 0804a040 B _ZSt4cout@@GLIBCXX_3.4  
    14.          U _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@@GLIBCXX_3.4  
    15. 0804a0d4 b _ZStL8__ioinit  
    16.          U _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@@GLIBCXX_3.4  
    17. 08049f00 d __CTOR_END__  
    18. 08049ef8 d __CTOR_LIST__  
    19. 08049f08 D __DTOR_END__  
    20. 08049f04 d __DTOR_LIST__  
    21. 080488c8 r __FRAME_END__  
    22. 08049f0c d __JCR_END__  
    23. 08049f0c d __JCR_LIST__  
    24. 0804a02c A __bss_start  
    25.          U __cxa_atexit@@GLIBC_2.1.3  
    26. 0804a024 D __data_start  
    27. 080487b0 t __do_global_ctors_aux  
    28. 08048610 t __do_global_dtors_aux  
    29. 0804a028 D __dso_handle  
    30.          w __gmon_start__  
    31.          U __gxx_personality_v0@@CXXABI_1.3  
    32. 080487aa T __i686.get_pc_thunk.bx  
    33. 08049ef8 d __init_array_end  
    34. 08049ef8 d __init_array_start  
    35. 08048740 T __libc_csu_fini  
    36. 08048750 T __libc_csu_init  
    37.          U __libc_start_main@@GLIBC_2.0  
    38. 0804a02c A _edata  
    39. 0804a0d8 A _end  
    40. 080487dc T _fini  
    41. 080487f8 R _fp_hw  
    42. 08048508 T _init  
    43. 080485e0 T _start  
    44. 0804a0cc b completed.7065  
    45. 0804a024 W data_start  
    46. 0804a0d0 b dtor_idx.7067  
    47. 08048670 t frame_dummy  
    48. 08048694 T main  

    上面便是testq个E序中所有的W号Q首先需要介l一下上面的内容的格式:

    •W一列:当前W号的地址
    •W二列:当前W号的类?br style="font-size: 0.95em;" />•W三列:当前W号的名U?br style="font-size: 0.95em;" />在上面的l果中,像_ZN4Test5HelloEvq样的符P很多读者朋友可能会被它搞晕Q这里介l个技巧,在nm的时候,加上-C选项Q就可以把这些难以识别的W号Q{换成便于我们阅读的符号TestHello()。这个主要是c++中的mangle机制所D的,加上-C是指定列出的符hdemangle了的。说了这么多Q到底nmҎ们程序有啥具体的帮助呢,我觉得主要有以下几个斚wQ?br style="font-size: 0.95em;" />Q?Q判断指定程序中有没有定义指定的W号 (比较常用的方式:nm -C proc | grep symbol)
    Q?Q解决程序编译时undefined reference的错误,以及mutiple definition的错?/p>

    Q?Q查看某个符L地址Q以及在q程I间的大概位|(bss, data, text区,具体可以通过W二列的cd来判断)

    本文要介l的ldd和nm是linux下,两个用来分析E序很实用的工具。ldd是用来分析程序运行时需要依赖的动态库的工Pnm是用来查看指定程序中的符可相关内容的工兗下面通过例子Q分别来介绍一

    相关推荐



    Prayer 2019-04-03 15:56 发表评论
    ]]>
    ŷƷ˿þþĻ| ھƷ˾þþþ777| պƷþþվ| þۺ97ɫֱ| þþƷƷapp| 99þùۺ| þþƷ99þ޶| ھƷþþӰԺ| ?VþþƷ | һƷþ| þþƷAVȫ| þ99Ʒþþþ| þۺϾƷþ| ھƷþþþþҰ| þѾƷһ| ŷ޹Ʒþѿ| ݺݾþۺ| Ʒþþþþþ˿| Ʒþþþþ| ɫվwwwþþ| þ99ڹ| ĻƷѾþþ| þþþ| ˾þô߽ۺͼƬ| þۺ| ޹˾þۺһ| þŷ޹ۺ| þþþþþƷͼƬ| þþƷAV͵ | þۺɫ֮þۺ| պŷۺϾþ | þþþĻƷ| þþþù| 91Ʒþþþþio| Բľþþþþ| 97þۺɫdžѿ| þþƷAV뽿ɫ| þٸ۲AV| þԭavapp| þþƷһ| avþþþòվ|