The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search and replace jobbyjoseph Shell Programming and Scripting 12 02-07-2008 02:33 AM
Perl: Search for string on line then search and replace text Crypto Shell Programming and Scripting 4 01-04-2008 10:24 AM
Search & replace videsh77 Shell Programming and Scripting 1 01-14-2005 07:10 AM
Help, sed search&replace mle Shell Programming and Scripting 2 02-13-2004 01:28 PM
search and Replace mukeshannamalai UNIX for Advanced & Expert Users 4 09-14-2001 06:21 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-03-2008
aks__ aks__ is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 5
how can the search and replace can be done interactively

hi,

To search and replace a string in multiple files i am using following command:
find . -name '*.txt' -print0 |xargs -0 perl -pi -e 's/find_string/replace_string/g'

I want to be prompted while replacing the string.
how this can be done.

thanks for every help.
  #2 (permalink)  
Old 06-03-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
In theory, simply replace the Perl script with one which prompts you for each substitution. In practice, for usability reasons, you would probably want to use the search and replace features of an editor, and simply feed the editor with a simple script. That way, you get undo, a nice way for the user to see the wider context of each change, and of course, the ability to make unrelated edits when you see something which needs fixing, etc. I personally recommend Emacs, but whatever editor you, or your users, are familiar with should do (unless it's too GUIey for its own good ...).
  #3 (permalink)  
Old 06-04-2008
aks__ aks__ is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 5
thanks.
yes, replacing it with an interactive perl script has solved the issue.
the other suggestion would certainly help in a broader context.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0