[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-user
Subject:    [gentoo-user] Re: OT: global search and replace
From:       "Alexander W. Skwar" <listen () alexander ! skwar ! name>
Date:       2004-09-10 13:54:11
Message-ID: 4141B203.3020008 () mid ! message-center ! info
[Download RAW message or body]

Andrew Ross wrote:
> On Fri, 2004-09-10 at 14:23, Alexander Skwar wrote:
> 
>>Billy Holmes wrote:
>>
>>>Alexander W. Skwar wrote:
>>>
>>>
>>>
>>>>>>	sed -i 's/oldhostname/newhostname/g' "${FILE}"
>>>>>
>>>>>perl makes this easier..
>>>>
>>>>In how far?
>>>
>>>
>>>it takes care of the backup files for you, perl's -i does't create 
>>>backups unless you specify an extension like -i.bak
>>
>>Okay, and how does that differ from sed? If you'd read the man page
>>of sed, you'd find:
>>
>>       -i[suffix], --in-place[=suffix]
>>
>>              edit files in place (makes backup if extension supplied)
>>
>>No extension (==suffix), no backup.
>>
>>
>>>therefore, no need for a block of shell code to remove the tmp files. 
>>>thus easier in this case means less work.
>>
>>Yes. That block's redundant.
> 
> 
> No, it's neccessary (at least on my system).

Strange.

> 
> The comment explicitly says it is removing "temp" files, not backups.

Oh, yes, that's right, it does not. Did you

> For whatever reason, sed -i creates these (empty) files in the current
> working dir

Not here, with GNU sed v4.0.9 on HP-UX and Gentoo.

On HP-UX I did:
ls -la . ; /usr/local/bin/sed --version > testfile ; cat testfile ; ls -la \
. ; /usr/local/bin/sed -i 's|by law.|__FOO BAR__|' testfile ; ls -la . ; \
cat testfile

And got:

total 8
drwxr-xr-x    2 vz6tml   pcei         4096 Sep 10 15:52 .
drwxrwxr-x    6 vz6tml   pcei         4096 Sep 10 08:57 ..
GNU sed version 4.0.9
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
total 12
drwxr-xr-x    2 vz6tml   pcei         4096 Sep 10 15:52 .
drwxrwxr-x    6 vz6tml   pcei         4096 Sep 10 08:57 ..
-rw-rw-r--    1 vz6tml   pcei          255 Sep 10 15:52 testfile
total 12
drwxr-xr-x    2 vz6tml   pcei         4096 Sep 10 15:52 .
drwxrwxr-x    6 vz6tml   pcei         4096 Sep 10 08:57 ..
-rw-rw-r--    1 vz6tml   pcei          259 Sep 10 15:52 testfile
GNU sed version 4.0.9
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted __FOO BAR__

On Gentoo:
insgesamt 4
drwxr-xr-x  2 alexander alexander    6 10. Sep 15:53 .
drwxr-xr-x  3 alexander alexander 4096 10. Sep 15:53 ..
GNU sed Version 4.0.9
Copyright (C) 2003 Free Software Foundation, Inc.
(Der folgende Text ist eine nicht überprüfte Übersetzung, die zur
 Information dient;  in rechtlichen Fragen ist immer das englische
 Original ausschlaggebend)

Dieses Program ist freie Software; In den Quelldateien können Sie die
Bedingungen für die Weitergabe nachlesen.
Es gibt KEINE GARANTIE; nicht einmal die implizite Garantie der
MARKTFÄHIGKEIT oder der ERFÜLLUNG EINES BESTIMMTEN ZWECKES.
insgesamt 8
drwxr-xr-x  2 alexander alexander   21 10. Sep 15:55 .
drwxr-xr-x  3 alexander alexander 4096 10. Sep 15:53 ..
-rw-r--r--  1 alexander alexander  469 10. Sep 15:55 testfile
insgesamt 8
drwxr-xr-x  2 alexander alexander   21 10. Sep 15:55 .
drwxr-xr-x  3 alexander alexander 4096 10. Sep 15:53 ..
-rw-r--r--  1 alexander alexander  469 10. Sep 15:55 testfile
GNU sed Version 4.0.9
Copyright (C) 2003 Free Software Foundation, Inc.
(Der folgende Text ist eine nicht überprüfte Übersetzung, die zur
 Information dient;  in rechtlichen Fragen ist immer das englische
 Original ausschlaggebend)

Dieses Program ist freie Software; In den Quelldateien können Sie die
Bedingungen für die Weitergabe nachlesen.
Es gibt KEINE GARANTIE; nicht einmal die implizite Garantie der
MARKTFÄHIGKEIT oder der ERFÜLLUNG EINES BESTIMMTEN ZWECKES.

Alexander Skwar
-- 
panic("aha1740.c"); /* Goodbye */
	2.2.16 /usr/src/linux/drivers/scsi/aha1740.c
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯


--
gentoo-user@gentoo.org mailing list

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic