keyword locating files in shell programming files

Source: Internet
Author: User
Tags regular expression

Come back tonight, write the fourth question, just want to match IP, that regular expression is too disgusting ...

I remember writing before ... But, forget where to put ....

The author of the script test files are thrown into a directory, because the practice is too large, so a directory, all the time named directory, and each directory file name is test1.sh,test2.sh....test10.sh .... At least hundreds of of them ....

And the author wants, is one day, writes a script, the author only remembers that script inside looks like uses the ping keyword ... So the demand came out:

The code is as follows:

#!/bin/bash  
#Author: MOS  
#Script name:keyfind  
#Date & time:2012-10-09/23:56:59  
#Version: 1.0.1  
#Description:  
#  
#找打笔者脚本目录的位置下, all the general files are thrown into the array  
array= (' find/root/shellscripts/-type f ')  
# Loop through each file, use grep to filter keywords ("positional parameters"), and when filtered, print out the name for  
I in ${array[*]};d o
    grep $i &>/dev/null & & echo "$i" done

This article from the "Self-Improvement" blog, please be sure to retain this source http://mos1989.blog.51cto.com/4226977/1020067

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.