locked
add text to the start of a line RRS feed

  • Question

  • (get-content "c:\temp\myfile.txt") | foreach { $_ + "#" } 

    When I run this line of code it adds the # to the end of the line, not the beginning.   This text file has about 1,400 records and I need to add a # to the beginning of each line.


    Thursday, June 1, 2017 9:03 PM

Answers

  • did you try
    (get-content "c:\temp\myfile.txt") | foreach {"#" + $_ } 
    ?

    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    • Marked as answer by bellmonster Thursday, June 1, 2017 9:21 PM
    Thursday, June 1, 2017 9:16 PM

All replies

  • did you try
    (get-content "c:\temp\myfile.txt") | foreach {"#" + $_ } 
    ?

    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    • Marked as answer by bellmonster Thursday, June 1, 2017 9:21 PM
    Thursday, June 1, 2017 9:16 PM
  • that did the trick
    Thursday, June 1, 2017 9:22 PM