Search notes:

Powershell command noun: content

The command noun content deals with the content of items.
Commands related to the PowerShell command noun content:

Inplace editing

A combination of get-content, set-content and the -replace string operator allows to edit a file in place (much as might be done in Linux with sed -i).
The following (simple) pipeline modifies some.text: it replaces #text# with "Hello world" and #num# with 42.
$fileName = 'some.text'

( get-content  $fileName )              `
     -replace '#text#', '"Hello World"' `
     -replace '#num#' ,   42            |
  set-content  $fileName
Github repository about-PowerShell, path: /cmdlets/content/inplace-editing.ps1
Thus
The text is #text# and the
number is #num#.
Github repository about-PowerShell, path: /cmdlets/content/some.text.orig
becomes
The text is "Hello World" and the
number is 42.
See also search and replace text in a directory.

See also

Powershell command nouns

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/Windows/...', 1759390569, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Windows/PowerShell/command-inventory/noun/content/index(72): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78