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