[Lubuntu] Sed substitution with partially duplicate results

John Hupp lubuntu at prpcompany.com
Wed Dec 19 21:16:41 UTC 2012


On 12/19/2012 3:57 PM, wes wrote:
>> It takes this line:
>>    DEVICE
>> and replaces it with this:
>> DEVICE Lubuntu1:3551 Lubuntu1:3551
>
> if (1) the original line really is
>
>  DEVICE
>
> and (2) you have only run the script once on a given file, then i'm 
> stumped.
>
>
> regarding (1), is it possible the original line reads
>
>  DEVICE Lubuntu1:3551
>
> instead?
>
>
> regarding (2), of all the calls to s/// in your script, it is notable 
> that
>
>>    -e 's/DEVICE/DEVICE Lubuntu1:3551/' \
>
> is the only one that will modify its own output, if the script is run 
> again.
>
> so if you run the script on a file twice, any line
>
>  DEVICE
>
> will become first
>
>  DEVICE Lubuntu1:3551
>
> and then
>
>  DEVICE Lubuntu1:3551 Lubuntu1:3551
>
>
> -wes
>
> On Wed, 19 Dec 2012, John Hupp wrote:
>
>> I'm using a script with sed to modify a configuration file. The script:
>>
>> sed -i \
>>    -e 's/UPSCABLE usb/UPSCABLE ether/' \
>>    -e 's/UPSTYPE usb/UPSTYPE net/' \
>>    -e 's/DEVICE/DEVICE Lubuntu1:3551/' \
>>    -e 's/TIMEOUT 105/TIMEOUT 60/' \
>>    -e 's/NETSERVER on/NETSERVER off/' \
>>    -e 's/NISIP 0.0.0.0/NISIP 127.0.0.1/'
>> /etc/apcupsd/apcupsd.conf
>>
>> It all works fine except for this substitution:
>> -e 's/DEVICE/DEVICE Lubuntu1:3551/'
>>
>> It takes this line:
>>    DEVICE
>> and replaces it with this:
>> DEVICE Lubuntu1:3551 Lubuntu1:3551
>>
>> Does anyone know why?
>>
>
That is a nice observation.  I created the script on an LTSP server and 
then ran a utility to create a network boot image from the server 
environment.  And since first writing, I tested the script (again?) on 
the server, where it runs as expected without creating the duplicate 
"Lubuntu1:3551".  So it is only on the client where the duplicate appears.

I am forwarding this to the LTSP list to see if anyone there can figure 
out how the script could be running twice.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/lubuntu-users/attachments/20121219/cf508293/attachment.html>


More information about the Lubuntu-users mailing list