Search notes:

sed: In place editing

Without backup:

sed -i changes the content of a file without creating a backup.
sed -i s/PAT/REPL/ /path/to/file

With backup:

If the -i is followed by a suffix, a corresponding backup is created before the file is edited.
The following example Creates the backup file /path/to/file.bak and modifies /path/to/file.
sed -i.bak s/PAT/REPL/ /path/to/file

sed: couldn't open temporary file /path/to/unwritable/directory/sedXXXXXX: Permission denied

If using sed -i to edit a file in place, the user must have write permissions in the directory where the edit file is located because sed tries to create a temporary file with the modified content in this directory before overwriting the edited file with the temporary file.
If the user does not have write privileges on this directory, the error message sed: couldn't open temporary file /path/to/unwritable/directory/sedXXXXXX: Permission denied is thrown.

See also

Inplace editing with Perl and PowerShell.
sed

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758194329, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/sed/in-place-editing(65): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78