Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
We have a file that looks like this:
Partly Cloudy
33
Windy
Very Very Cold
North 15-25those values (and spaces in the text)
need to replace text in a different file
that text is: AAA, BBB, CCC, DDD, and EEE(where AAA is replaced by Partly Cloudy)
and so on...is there some simple way to do this?!
thanks!
i am a computer novice!

Hi:
I'm interpreting that you want every line in your file, and placed on one line delimited by a comma and a space. If this is correct, this command should work:
sed 's/$/| /g' mydata.file| xargs |sed 's/|/,/g'
The command above leaves a comma at the end of the line. You don't say whether this is what you want. This command removes the trailing comma:
sed 's/$/| /g' mydata.file| xargs |sed 's/|/,/g' |sed 's/,$//g'

actually...there is a GREAT DEAL of text in the target file (HTML, COLORS, OTHER DATA)
We need to be able to create the small file of 5 or six lines on a daily basis...
and then have the script replace the placeholders (AAA etc) with the new data!the big problem, is when we have
PARTLY CLOUDY as the first line of the
file, we seem to get PARTLY to replace AAA
and CLOUDY to replace BBB
(instead of PARTLY CLOUDY replacing just AAA)please help us!

FILE1:
Partly Cloudy
Very Windy
44
Some Fog Late
NE 10-15FILE2:
!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="sean archer">
<meta name="GENERATOR" content="Mozilla/4.8 [en] (Windows NT 5.0; U) [Netscape]">
<title>ktbc data</title>
<!-- saved from url=(0129)file://C:\Documents%20and%20Settings\ktbcuser\Local%20Settings\Temporary%20Internet%20Files\Content.IE<!-- saved from url=(0129)file://C:\Documents%20and%20Settings\ktbcuser\Local%20Setti</head>
<body>
<table BORDER COLS=5 WIDTH="83%" >
<tr>
<td><AAA></td>
<td><BBB></td>
<td><CCC></td>
<td><DDD></td>
<td><EEE></td>
script:
temps=`cat FILE1`
t1=`echo $var|cut -d" " -f1`
t2=`echo $var|cut -d" " -f2`
t3=`echo $var|cut -d" " -f3`
t4=`echo $var|cut -d" " -f4`
t5=`echo $var|cut -d" " -f5`sed -e 's/AAA/$t1/' -e 's/AAA/$t1/' \
-e 's/AAA/$t1/' -e 's/AAA/$t1/' \
-e 's/AAA/$t1/' \
FILE2 > FILE3

![]() |
![]() |
![]() |

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