Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Delete all text after string...

$
0
0

I have a series of text files that I am attempting to parse with PowerShell. I haven't done much with text file manipulation and would love some advice. Thanks in advance to anyone willing to give this a go!

Example File: (file name = "report_20131231.txt")

**** SAMPLE1 ****

user1 username1

user2 username2

user3 username3

**** SAMPLE2 ****

user4 username4

user5 username5

user6 username6


I want to import the text file and reformat it to the following:

Date             | SAMPLE #   | Username<file name date> | <sample #> | <username>

Example Output:

Date     |  SAMPLE # |  Username

20131231 |  SAMPLE 1 |  username1

20131231 |  SAMPLE 1 |  username2

20131231 |  SAMPLE 1 |  username3

20131231 |  SAMPLE 2 |  username4

20131231 |  SAMPLE 2 |  username5

20131231 |  SAMPLE 2 |  username6






Viewing all articles
Browse latest Browse all 21975

Trending Articles