D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

[LUG] Quick bash/sed script question

 

Hi,

I am trying to write a bash script to execute the same sed script on
several files, I am doing this way because I can't find out if I can do
it with sed directly.

When I tell sed to write the output back to the input file, I end up
with a blank file - very annoying. So I want the bash script to write
the output to the filename with a _ on the end of it.

#!/bin/bash
for filename in `ls /etc/analog/*.cfg`
do
        sed '/OUTFILE/ s/$/index.html/' $filename > $filename_
done

That is what I have so far, except it won't work because $filename_ is
undefined. How can I prepend a character to the end of a variable?

Thanks,

-- 
Seth Kneller

http://www.autismisanotherworld.com/~seth


--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe. FAQ: www.dcglug.org.uk/linux_adm/list-faq.html