Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 06 Feb 2009 22:50:38 +0000
From:      Adam Vande More <>
Subject:   insert new line in files
Message-ID:  <>

Next in thread | Raw E-Mail | Index | Archive | Help
I want to insert a new line of text at a certain position in certain 
files recursively under a directory.  More specifically, I want text 
like this:


to be put into file X at line 37 where file X appears in ./subdir1, 
.subdir2 etc. There are many subdirs or I'd just do it by hand.

I've done stuff like this before with the rpl script and it works well 
as long as there aren't any special characters in the strings.  So I 
assumed I finally hit the point where I'm forced to learn something like 
sed or awk and tried some examples with sed but I can't figure out what 
I'm doing wrong.

I get results like this:

sed '5i\test' test.txt
sed: 1: "5i\test": extra characters after \ at the end of i command

Is sed the right tool for this?  If so, any good primers for BSD sed?

Want to link to this message? Use this URL: <>