[YLUG] How do to substition in a file with sed or similar
David Matthews
dmatthews at mailc.net
Fri Oct 27 13:10:27 BST 2006
On Fri, 27 Oct 2006 12:15:19 +0100
york-request at mailman.lug.org.uk wrote:
> How I do the substition on the file 'in place'?
This demonstrates what you want I think, but don't ask me how. Its from a script I wrote to LilyPond/Musixtex NoteEdit output.
Sed 's a 'mare. I (eventually) get it to do what I want, bung it in a script and run screaming from the room.
#if the TeX file doesn't contain a musicsize instruction, insert one
if ! grep "musicsize" $FILE > /dev/null; then
sed '/nobarnumbers/i\\normalmusicsize' $FILE > temp.tex
mv temp.tex $FILE
fi
#substitute musicsize instruction as per command line
#some versions of sed don't understand * so need two passes
if grep "normalmusicsize" $FILE > /dev/null; then
sed /normal/s/normalmusicsize/$RP/ $FILE > temp.tex
else sed /musicsize/s/.....musicsize/$RP/ $FILE > temp.tex
echo "Temporary TeX file created"
fi
--
David
dmatthews at mailc.net
Public key at hkp://www.keys.eu.pgp.net
and http://pooter.sourceforge.net/dmatthews.asc
"If our nation can issue a dollar bond, it can issue a dollar bill. The
element that makes the bond good makes the bill good ?
It is absurd to say that our country can issue $30,000,000 in bonds and
not $30,000,000 in currency." [Thomas Edison, Quoted in The New York Times, 6 December 1921]
http://www.prosperityuk.com/prosperity/prosperity.html
More information about the York
mailing list