lefang的个人博客分享 http://blog.sciencenet.cn/u/lefang 湍流,计算流体力学

博文

按段进行grep检索

已有 3865 次阅读 2010-5-10 16:43 |个人分类:GNU Linux|系统分类:科研笔记| grep

翻译自 Arch linux magazine 2009年5月刊

在Tru64下grep有个很酷的参数-p,允许按段进行grep检索。但其他非Tru64的linux系统也可以通过自定义一个函数达到同样的目的。只需要在.bashrc里面加上

grepp() {
if test -z "$1" || test -z "$2" ; then
echo "USAGE: grepp searchterm
filetosearch";
else
perl -00ne "print if /$1/i" < $2
fi }

之后即可使用grepp,如下

[crouse@veronica ~]$ grepp DAE /etc/rc.conf
#
# -------------------------------------------------------------------------------------------------
# DAEMONS
# -------------------------------------------------------------------------------------------------
#
# Daemons to start at boot-up (in this order)
# - prefix a daemon with a ! to disable it
# - prefix a daemon with a @ to start it up in the background
#
DAEMONS=(syslog-ng hal !dbus network netfs @openntpd @crond @sshd)
[crouse@veronica ~]$

https://wap.sciencenet.cn/blog-423882-322334.html

上一篇:Archlinux下让terminal下的vim支持X剪贴板
下一篇:几个vim模块和fortran环境的注释增强
收藏 IP: .*| 热度|

0

发表评论 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-19 16:02

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部