Computing.Net > Forums > Unix > One more Q. (find and replace)

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

One more Q. (find and replace)

Reply to Message Icon

Name: amir
Date: December 6, 2003 at 23:25:47 Pacific
OS: unix- solaris
CPU/Ram: sun ultra10
Comment:

Hi all,
I have a script that scan files, find old templet and replace it with new one.

#!/bin/ksh
file_name=$1
old_templet=$2
new_templet=$3

# Loop through every file like this
for file in file_name
do
cat $file | sed "s/old_templet/new_templet/g" > $file.new
#do a global searce and replace and put the results
mv $file.new $file
#rename $file.new to original name of file
done


How can I replace the old templet with few rows templet ?
for example:
the old templet =
xxxx
the new templet =
yyyy
zzzz

<script_name> <file_name> xxxx yyyy??zzzz

What has to be instead the ?? in order to split the yyyy and zzzz for tow separate rows ?

10x
Amir




Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


reading colon delimited d... help file system watcher ...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: One more Q. (find and replace)

unix script - find and replace www.computing.net/answers/unix/unix-script-find-and-replace/5816.html

Need help with a search and replace logi www.computing.net/answers/unix/need-help-with-a-search-and-replace-logi/3296.html

Find and replace directories www.computing.net/answers/unix/find-and-replace-directories/7816.html