Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    3

    Red face Unanswered: Find and replace in unix

    Hi
    I have to problem with a find and replace with command unix and perl
    i use this sentence for find and replace a text:

    # find . -name '*.shtml' | xargs perl -p -i -e 's/Salio/sisepuede/i'


    but i have this problem

    Can't open ./prueba: No such file or directory, <> line 902.
    Can't open ssss.shtml: No such file or directory, <> line 902.


    this problem is because my file name is "./prueba ssss.shtml" and the
    "xargs" take this file like two file: "./prueba" , "ssss.shtml" .

    I need fix this error, how i can fix this error and take this file like one.


    Thank for you help.
    Good Day

  2. #2
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525

    Re: Find and replace in unix

    Try...
    Code:
    find . -name '*.shtml' | IFS=# xargs perl -p -i -e 's/Salio/sisepuede/i'

  3. #3
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    If your find supports thr -printf option, yo can do :

    Code:
    find . -name '*.shtml' -printf "'%p' " | xargs perl -p -i -e 's/Salio/sisepuede/i'
    If it's not the case, you can do :

    Code:
    find . -name '*.shtml' -exec perl -p -i -e 's/Salio/sisepuede/i' '{}' \;
    Jean-Pierre.

Posting Permissions

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