Find the answer to your Linux question:
Results 1 to 3 of 3
Hi All, I want to know whether i can use both grep and vi together and open different files having the same expression in them in one cpmmand. Something like ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2008
    Posts
    9

    To open multilple Files containg a particular expression


    Hi All,

    I want to know whether i can use both grep and vi together and open different files having the same expression in them in one cpmmand.

    Something like this :
    vi `grep -lR` Hai` "*.*"
    But the above command is not working. Can any one please correct me if
    i am doing anything wrong or is there any other way to achieve the same.


    Thanks & Regards
    Vikram

  2. #2
    Just Joined!
    Join Date
    Aug 2007
    Posts
    25
    Quote Originally Posted by vicky_brsh View Post
    Hi All,

    Something like this :
    vi `grep -lR` Hai` "*.*"
    Are you trying to edit files that have Hai in the file, or edit the file returned by the grep? I suspect the first.

    try

    vi `grep -lR Hai *.*`

    that will edit every file that has the letters Hai anyplace in the file.

  3. #3
    Just Joined!
    Join Date
    Nov 2008
    Posts
    26
    <SOAPBOX>
    Keep in mind also folks, that Linux is not Winblows. *.* does not necessarily do what you think it will do. On Windows, it will pull out any file (even files that have no extension). On Linux, this means "any file whose name contains a period." On Linux, for example,
    > ls -al /etc/hos*.*
    will not show you /etc/hosts (unlike Winblows)

    What you really want (probably), is to replace "*.*" with *
    </SOAPBOX>

    D

Posting Permissions

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