Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2003
    Posts
    11

    Unanswered: How do i find out where a certain line is

    Hi,

    I am new to Solaris and I would like find out in which file a certain line 'abc' exists.
    i tried using grep but it did not return any values.
    i tried to use grep from root as i am not sure in which file that particular line 'abc' exists.

    thanks and regards.

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: How do i find out where a certain line is

    Can you post the command you used ...

    Cheers

    Sathyaram

    Originally posted by jeyagowri
    Hi,

    I am new to Solaris and I would like find out in which file a certain line 'abc' exists.
    i tried using grep but it did not return any values.
    i tried to use grep from root as i am not sure in which file that particular line 'abc' exists.

    thanks and regards.

  3. #3
    Join Date
    Mar 2003
    Posts
    12

    Re: How do i find out where a certain line is

    Hi Jeyagowri,

    Please try this.

    find / -exec grep "search_pattern" '{}' \; -print

    Rgds,

    Srini.

    Originally posted by jeyagowri
    Hi,

    I am new to Solaris and I would like find out in which file a certain line 'abc' exists.
    i tried using grep but it did not return any values.
    i tried to use grep from root as i am not sure in which file that particular line 'abc' exists.

    thanks and regards.

  4. #4
    Join Date
    Mar 2003
    Posts
    12

    Re: How do i find out where a certain line is

    This would take more time since it is searching from root.

    Originally posted by g_srinivas
    Hi Jeyagowri,

    Please try this.

    find / -exec grep "search_pattern" '{}' \; -print

    Rgds,

    Srini.

  5. #5
    Join Date
    Apr 2003
    Location
    Bangalore (India)
    Posts
    2

    Try using xargs

    Hi,

    To find a string or a line in a set of files..you can try this command

    find / -name "*.*" -print | xargs grep "<search pattern>"

    This will search through all the files..if you know the type of the file..say "c" files or perl files "*.pl" you can modify the command accordingly..this will minimize the search time...

    Typically, your command should look something like this...

    find / -name "*.c" -print | xargs grep "abc"

    Hope this helps

    Regards,
    Bharath (bharathanv@epatra.com)

  6. #6
    Join Date
    Jun 2003
    Posts
    3
    If you put /dev/null (for example) you'll get files in

    find / -type f -exec grep "string" /dev/null {} \;

    /J

  7. #7
    Join Date
    Jul 2003
    Location
    US
    Posts
    314

    Talking Grep results

    You could perform the search by just using grep only.

    Try the following command in the root.


    grep -lRia "pattern" *

    This would look for all the files for a case-insensitive pattern in all the files.

    You could modify the above command by looking for only certain type of files like

    grep -lRia "pattern" *.pl

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •