views:

124

answers:

1

Hello,

I am trying to change the content of a specific line in a batch of files. I thought that would be a piece of cake but for some reason, nothing happens, so I guess I am missing something. Line 8 should have been replaced.

Here the csh script I used:

#!/bin/csh
#
# replace context in line xxx by yyy
# 2010/05/07

set files = `ls FILENAMEPART*`
echo $files
foreach file  ($files)
        sed  '8,8 s/1/2 /' $file 
end

thanks for suggestions

+1  A: 

sed prints the resulting file (with the lines replaced) to stdout by default and leaves the source (input) file untouched. Use the -i option for in-place editing, which means that the changes are made directly in $file.

jkramer
thanks a million :)
not_a_geek
You're welcome. Please accept the answer if it solves your problem.
jkramer
sure, i was just waiting for the minutes to pass before I was allowed to
not_a_geek