grep and sed equivalent in PowerShell grep and sed equivalent in PowerShell powershell powershell

grep and sed equivalent in PowerShell


Use the -match and -replace operators:

(svn info filename) -match '^Last Changed Date:' -replace '^Last Changed Date: '


To remove the leading label you could use a capture group with the RegEx pattern.

svn info filename | Select-String '^Last Changed Date: (.*)$' | ForEach-Object{$_.Matches.Groups[1].Value)

Or taking Ansgars approach without the match (and repeating the label)

(svn info filename) -replace "(?sm).*?^Last Changed Date: (.*?)$.*","`$1"