Find the answer to your Linux question:
Results 1 to 2 of 2
I am using this command: Code: sed -i 's?,\$HTTP_USER_AGENT,?,$HTTP_USER_AGENT."\nFile: ".__FILE__."\nLine: ".__LINE__,?g' *.php to modify a line in my php files. I want to do this recursively from the directory I ...
  1. #1
    Just Joined!
    Join Date
    Apr 2003
    Posts
    52

    problem using sed

    I am using this command:

    Code:
    sed -i 's?,\$HTTP_USER_AGENT,?,$HTTP_USER_AGENT."\\nFile: ".__FILE__."\\nLine: ".__LINE__,?g' *.php
    to modify a line in my php files. I want to do this recursively from the directory I am in. but I get this message in response:

    sed: can't read *.php: No such file or directory

    sed version is 4.1.2

    It's important that I only change *.php files, and do so recursively. Can anyone help? Thank you!

  2. #2
    Linux Engineer Freston's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    1,047
    I think you can't put wildcards in filenames for this operation.


    This may be a solution:
    Code:
    for i in `ls *php` ; do 
       sed $options $i 
    done
    Can't tell an OS by it's GUI

Posting Permissions

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