If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Find and replace in unix

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-24-04, 17:36
joalpeca1 joalpeca1 is offline
Registered User
 
Join Date: Mar 2004
Posts: 3
Red face 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
Reply With Quote
  #2 (permalink)  
Old 03-25-04, 04:31
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
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'
Reply With Quote
  #3 (permalink)  
Old 03-25-04, 08:13
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On