D&C GLug - Home Page

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

Re: [LUG] Quick bash/sed script question

 

Seth Kneller wrote:

>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.
>  
>
How about

sed -i '/OUTFILE/ s/$/index.html/' /etc/analog/*.cfg

Pete

>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,
>
>  
>


--
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