Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 操作系统 > Linux > 小脚本:用shell摹拟grep -i
【标  题】:小脚本:用shell摹拟grep -i
【关键字】:shell,grep
【来  源】:http://www.cublog.cn/u/126/showart.php?id=154370

小脚本:用shell摹拟grep -i

Your Ad Here ================================================================ /home/lee#cat Grep #!/bin/bash # (($#!=2))||[[ ! -f $2 ]]&&{ echo "Usage:$(basename $0) filename"; exit 1; } str=$(echo $1|od -b) str=${str% *} str=${str#* } patten=$( for i in $str;do [[ $i == 14[0-9] ]] && echo -ne "\\0133\\0${i/4/0}\\0$i\\0135" ||\ echo -ne "\\0133\\0${i/0/4}\\0$i\\0135" done ) while read line;do [[ $line == *$patten* ]] && echo $line done<$2 ================================================================ test: /home/lee#chmod +x Grep /home/lee#cat file abcd aBcD Abcabc AbCd aaaasadfsdf bbb ccc /home/lee#grep -i abcd /home/lee#grep -i abcd file abcd aBcD AbCd /home/lee#Grep abcd file abcd aBcD AbCd /home/lee#
模仿perl区间操作:【上一篇】
[小函数]:随机产生N位字符串:【下一篇】
【相关文章】
  • 几种shell里的小括号,大括号结构和有括号的变量,命令的用法
  • shell编程13问
  • shell编程入门
  • Linux shellcode abstract tool V .0.2
  • String operators in bash shell
  • 第四部分 基础shell编程
  • phpwind后台获得shell
  • 把shell变量传给awk
  • SHELL病毒简介
  • Linux Shell常用shell命令
  • 【随机文章】
  • 3DS MAX打造新春祝福
  • Network Programming Using Internet Sockets (三)
  • 我的个人介绍&工作经历
  • 应用程序框架设计(2):SW系统的窗口类
  • Sleipnir 基于IE内核的绿色多页面浏览器
  • 贪吃蛇 J2ME 的实现 (简单程序,练练手艺) 0.1版本
  • SUSE FAQ 系列 -- LVS Client 持久设置
  • Windows中的名言警句??
  • ODBC 连接数据源
  • IPv6 基础知识
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.