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 2 weeks 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: 8
      Replies: 1151
      Points: 3,995
      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: 2
      Replies: 1687
      Points: 3,340
      Helping Hand
      Rank: Community Hero

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

Viewing 2 reply threads
  • You must be logged in to reply to this topic.