Select rows in a text file based on start and end words

Welcome Forums General PowerShell Q&A Select rows in a text file based on start and end words

  • This topic has 2 replies, 3 voices, and was last updated 7 months ago by
    Participant
    .
Viewing 2 reply threads
  • Author
    Posts
    • #196523
      Participant
      Topics: 2
      Replies: 0
      Points: 13
      Rank: Member

      Hi,

      I have a log file which contains data like the below:

      Person Name: User 1
      Data

      Data
      Total:
      Person Name: User 2
      Data

      Data
      Total:

      I want to use the ‘Select-String’ command in order to select all the rows starting from the row containing ‘User 1’ until ‘Total’ after ‘User 1’, and export all of these rows to a file named ‘User 1’, and all rows starting from the row ‘User 2’ until the row Total after ‘User 2’, and so on,

      Anyone have an idea how this can be accomplished?

      Thanks,
      Amichai

    • #196547
      Senior Moderator
      Topics: 9
      Replies: 1259
      Points: 4,553
      Helping Hand
      Rank: Community Hero

      pretty much doable, but I would suggest you to try something with Select-String by reading the Help documentation.
      Folks here will definitely help when you get stuck.

    • #196553
      Participant
      Topics: 5
      Replies: 2411
      Points: 6,193
      Helping Hand
      Rank: Community MVP

      You may watch this video to get an overview what’s possible with Powershell: Sophisitcated Techniques of Plain Text Parsing.

Viewing 2 reply threads
  • The topic ‘Select rows in a text file based on start and end words’ is closed to new replies.