problem with script

there is a file test_jan2 in my present directory and i just need to replace some things and write into different file

the script looks like this

after this the test2 is being formed with 0 bytes. can somebody suggest?

#!/bin/ksh

while read i
do
    sed -e 's/google/rediff/g' -e 's/streams/promos/g' "${i}" > test2
done < test_jan2

still the same problem

+ sed -e s/google/rediff/g -e s/streams/promos/g google
+ 1> test2
Can't open google
+ read i
+ sed -e s/google/rediff/g -e s/streams/promos/g streams
+ 1> test2
Can't open streams
+ read i
+ sed -e s/google/rediff/g -e s/streams/promos/g google
+ 1> test2
Can't open google
+ read i
+ sed -e s/google/rediff/g -e s/streams/promos/g streams
+ 1> test2
Can't open streams
+ read i

ok, 'google' and 'streams' don't exist where 'sed' expects them.

Maybe I don't understand what you're after, but...

Does 'test_jan2' contain a list of files to be edited
OR
Do you want to edit 'test_jan2' files itself?

Hi dsravan,
sed can work the entire file (it may take the test_jan2 as an input). So I don't see the need for it to be fed line by line (for loop). Also if using a loop, you would need to redirect output using the >> to append (> would only overwrite the last line).

Please try this and let us know:

sed -e 's/google/rediff/g' test_jan2 | sed -e 's/streams/promos/g' > test2

If you are using the for loop because you have multiple files, just move the output redirection to the end:

#!/bin/ksh

for i in test_jan2; do
cat $i | sed 's/google/rediff/g' | sed 's/streams/promos/g'
done > test2

sed is a stream editor, which means it transforms a flow of input into a flow of output by following a flow of instructions. As I can see from your example, you are not providing input to sed; please check the command syntax, as there must be an input source specified or implied. By using the for loop, no standard input is being implied, so at least a filename has to be provided in sed invocation, as: sed 'flow of instructions' input_filename. Also please check the syntax to provide two or more instructions in the same line, because if you don't then you should use "( sed 'command_1' | sed 'command_2' ) <input_filename >output_filename" explicitly.
Hope it helps.

Why exactly do you need a 'cat'?

Also, in the future please use vB Codes when posting data or code samples I've edited your post for ease of reading.

Don't necessarily need it, just habit.

Speaking of bad UUOC habits.