Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can PowerShell dot notation be used on multiple lines?

Tags:

powershell

To make scripts more readable I would like to break things up on multiple lines. Is this possible in PowerShell's dot notation?

For example, take this:

(GC myfile.txt).Replace('a',b').Replace('c','d').Replace('e','f') | SC newfile.txt

And write it like this:

(GC myfile.txt).Replace('a',b')
    .Replace('c','d')
    .Replace('e','f') |
    SC newfile.txt

I have tried using backticks (`) and they don't work. Are there any options? I guess assume PowerShell v3+

like image 954
Brettski Avatar asked Apr 17 '15 14:04

Brettski


1 Answers

I found the same issue, the easiest way to solve it is to place the point before breaking the line

(GC myfile.txt).Replace('a',b').
    Replace('c','d')
like image 194
Naigel Avatar answered Sep 26 '22 03:09

Naigel