[Gllug] error in bash script to rename files in a directory

Nix nix at esperi.demon.co.uk
Sun Jan 5 20:03:11 UTC 2003


On Tue, 31 Dec 2002, Stig Brautaset spake:
>                                                   I've found myself many
> times wanting a 'same file' flag to sed. That would ease these cases a
> bit, but I'm not sure it's a good idea for other reasons.

Your call has been heeded in GNU sed 4.0.x:

`-i[SUFFIX]'
`--in-place[=SUFFIX]'
     This option specifies that files are to be edited in-place.  GNU
     `sed' does this by creating a temporary file and sending output to
     this file rather than to the standard output.(1)

     When the end of the file is reached, the temporary file is renamed
     to the output file's original name.

     The extension, if supplied, is used to modify the name of the old
     file before renaming the temporary file (thereby making a backup
     copy(2)) following this rule: if the extension doesn't contain a
     `*', then it is appended to the end of the current filename as a
     suffix; if the extension does contain one or more `*' characters,
     then _each_ asterisk is replaced with the current filename.  This
     allows you to add a prefix to the backup file, instead of (or in
     addition to) a suffix, or even to place backup copies of the
     original files into another directory (provided the directory
     already exists).

     This option implies `-s'.

This version of GNU sed includes a myriad of very silly features,
including things like run-a-shell-command-on-the-result-of-this-
substitution...

-- 
`I was thinking of the legendary British Weather, with the four seasons
 of winter, mud, rain, and damp.' --- Peter da Silva

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list