The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to find a file named vijay in a directory using find command amirthraj_12 UNIX for Dummies Questions & Answers 6 10-25-2008 09:37 AM
Can I know find syntax to find given date files bache_gowda Shell Programming and Scripting 3 03-26-2008 03:37 AM
Little bit weired : Find files in UNIX w/o using find or where command jatin.jain Shell Programming and Scripting 10 09-19-2007 03:47 AM
Find files older than 20 days & not use find halo98 Shell Programming and Scripting 2 05-18-2006 11:19 AM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 03:38 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-04-2008
Registered User
 

Join Date: Jun 2007
Posts: 45
find and repalce

Hi i would like to know about find and replace command:
i have files like:

temp1:
Code:
unix
windows
Calender
tools
I would like output like:
temp1:
Code:
unix
unix
Calender
tools
thanks

Last edited by Yogesh Sawant; 04-04-2008 at 06:04 AM. Reason: added code tags
Reply With Quote
Forum Sponsor
  #2  
Old 04-04-2008
Yogesh Sawant's Avatar
Part Time Moderator and Full Time Dad
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 796
if you can use Perl:
Code:
perl -pi -e 's/windows/unix/' newfile
Reply With Quote
  #3  
Old 04-04-2008
Registered User
 

Join Date: Apr 2008
Posts: 3
Here is a little script I use which does the same thing as Yogesh suggested. Simply call the script with oldvalue and newvalue -- every file in the directory will be updated so use with care

#!/bin/ksh

case $# in
0) echo "\nUsage: replace oldvalue newvalue\n"
exit 1
;;
*) echo "\n\n oldvalue: $1\t\t newvalue: $2\n\n"
echo "================================================"
echo "BEFORE"
echo "================================================"
grep $1 *
perl -pi -e "s/$1/$2/g" *
echo "================================================"
echo "AFTER"
echo "================================================"
grep $2 *
esac
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
perl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:45 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0