UNIX Script : Regarding find command

Posted on 2008-11-07
Last Modified: 2012-05-05
How do I search for specific text in a file in a directory.
Ex: I need to search for a file that contains systeminfo@localhost in /usr/local
Question by:jdenver247
    LVL 40

    Accepted Solution


    cd /usr/local
    grep 'systeminfo@localhost'

    or if you have sub directories, then

    find /usr/local -type f | xargs grep 'systeminfo@localhost'
    LVL 14

    Assisted Solution

    by:Deepak Kosaraju
    grep -i "systeminfo@localhost" /usr/local/\*
    LVL 1

    Assisted Solution


    grep -R -a1 -b1 systeminfo@locahost /usr/local/*

    -a1 -b1 shows the data 1 line above and below the text line begin searched on!


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
    The purpose of this article is to demonstrate how we can use conditional statements using Python.
    In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
    This tutorial goes over how to archive and restore FreeBSD jails that are managed by ezjail.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now