Articles of 正则expression式

从大量的电子邮件中挑出独特的发件人

我只是在Centos / home / user / mail / new中的用户帐户下find了一大堆电子邮件 我打开了他们中的一些,发现他们是从一个特定的cron工作发出的。 发件人地址是[email protected] 。 我需要找出所有这些电子邮件是否由[email protected]发送 – 这是约30GB的电子邮件。 有没有一种方法来刷出一个唯一的发件人列表的列表? 电子邮件的格式是这样的: 返回path: 信封到:[email protected] 交货date:星期四,2011年8月11日04:34:02 -0400 收到:从本地用户hostname.com(Exim 4.69) (信封来自) id 1QrQiI-0004qM-6V 为[email protected]; 星期四,11八月2011 04:34:02 -0400 来自:[email protected](Cron守护进程) 致:[email protected] 主题:Cron /opt/gsn/reports/pr.sh 内容types:text / plain; 字符集= UTF-8 自动提交:自动生成 邮件ID: date:2011年8月11日(星期四)04:34:02 -0400 [信息内容]

用perl / awk / sed预加string?

我正在尝试将脚本更改到我的apacheconfiguration文件(httpd.conf)。 我试图匹配下面的string: # # DirectoryIndex: sets the file that Apache will serve if a directory 并预备以下文本: # # Allow server status reports generated by mod_status, # with the URL of http://servername/server-status # Change the ".example.com" to match your domain to enable. # <Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from localhost ip6-localhost […]

在虚拟主机的定义中使用正则expression式

我必须在服务器configuration文件中定义大约100个子域虚拟主机条目。 我想知道是否有任何方法使用正则expression式来增加apacheconfiguration文件中的代码?

如何使用find命令清除所有文件的内容

是否有一个简单的步骤来清除使用find命令的所有“.log”文件的内容。 目前我使用“echo -n> filename.log”我已经尝试echo -n> /var/application-logs/*.log,但它不工作.. 有没有更好的方法来清除多个文件的内容?

sed regexp / d删除整个文件

给定一个典型的known_hosts文件: [123.45.67.89]:22 ssh-rsa bbuivvhbkbjdnflksndkfnksnfk… [98.76.54.32]:14444 ssh-rsa hohdibsodbfoasbfbsabdfbsd… [77.34.122.33]:32209 ssh-rsa bksdjncknsdbcksbdcbhdhhb… 不知道文件中的行号,但知道IP地址。 以下删除文件中的所有行: sed '/98\.76\.54\.32/d known_hosts > known_hosts' 我希望我只是错过了一些荒唐简单的东西。 在这里testing我的正则expression式给了我需要的匹配,我的印象是: sed '/pattern/d' file > file 应该只放下/ pattern /匹配的第一行。 我知道我不是正则大师,也不是bash高手,但我认真地想,这不会是一个search,两个咖啡的战斗。 任何人都可以扔我骨头? 编辑:4分钟的答案,所有权利。 我知道这是荒谬的。 希望我的愚蠢在别人的search中出现。

grep模式匹配不区分大小写

我想写一个grep函数来显示我的主机上的所有侦听端口。 我知道如何通过在grep中使用-ifunction来实现: netstat -a |egrep -i 'listen' 但现在我想写在正则expression式: netstat -a |egrep 'm/listen/i' 我想:因为netstat输出多行,我因为它是听,所以我想情况不敏感。 但是这不会给出任何输出。 我究竟做错了什么 ?

麻烦让用户通过Squid代理访问某些网站

我们有一个RHEL服务器上运行的Squid。 我们想阻止用户访问Facebook,除了一些特定的网站,比如我们的组织页面。 不幸的是,我不能让所有的Facebook通过这些特定的网页畅通无阻。 [squid.conf中] # Local users: acl local_c src 192.168.0.0/16 # HTTP & HTTPS: acl Safe_ports port 80 443 # File containing blocked sites, including Facebook: acl blocked dst_dom_regex "/etc/squid/blocked_content" # Whitelist: acl whitelist url_regex "/etc/squid/whitelist" # I do know that order matters: http_access allow local_c whitelist http_access allow local_c !blocked http_access deny all […]

将.htaccess中的mod_rewrite规则移至httpd.conf

我有一大堆的URL重写规则,我试图: 优化 转换到httpd.conf中使用 但是我正面临着让最终产品工作的问题。 注意:有其他人已经提到的优化: https : //webmasters.stackexchange.com/questions/4237/url-rewritten-pages-take-much-longer-to- (请看看这个) 注意:以下在.htaccess文件中完美工作 RewriteEngine On RewriteBase /abcd/ RewriteRule ^.*/codelibrary/(.*)$ codelibrary/$1 [L] RewriteRule ^.*/instructor_upload/images/(.*)$ instructor_upload/images/$1 [L] RewriteRule ^.*/content/image/(.*)$ content/image/$1 [L] RewriteRule ^.*/content/video/(.*)$ content/video/$1 [L] RewriteCond %{REQUEST_URI} !instructor_upload/(.*)\. RewriteRule ^.*/images/(.*)$ images/$1 [L] RewriteRule ^.*/flowplayer/(.*)$ flowplayer/$1 [L] RewriteRule ^.*/admin/ajax/(.*)$ admin/ajax/$1 [L] RewriteCond %{REQUEST_URI} !admin/(.*)\. RewriteRule ^.*/ajax/(.*)$ ajax/$1 [L] RewriteRule ^.*/banner_images/(.*)$ banner_images/$1 […]

Vim模式replace

<created> [email protected] </created> 我想要replace上面的用户名可能会有所不同,即pat @ c.com,harry @ c.com … <created> [email protected] </created> 在vim中replace这个命令是什么? %s/<created>\r*\r</created>/new string

通配符子域的htaccess

如何将示例url转换为所需的url? From http://test.at.domain.com To http://domain.com/at/index.php?at=test 我有: RewriteEngine on RewriteCond %{HTTP_HOST} (\w+).at.domain.com [NC] RewriteRule .* http://domain.com/at/index.php?at=%1 [L] 然而,浏览器说:“它表示抱歉,这个网站目前不可用”这是formsgodaddy.com