What would be the order to remove everything after a string (\ test.something) I have the information in a text file, but after string there is a 1000 lines that I do not want. How can I remove everything after string and including?
It's with me - not working very much Thanks.
$ file = get-item "C: \ Temp \ test.txt" (Get-content $ file) | For pre {$ _. Trim ("\ test.something \")} | Set-content $ file
Why remove everything? Just keep everything up (I'm going to use two rows for readability, but you can easily add it to a command):
$ text = (Get-content test .txt | Out-String). Trim () # Note V3 can only use get-content test.txt- $$ text. Substrings (0, $ text.IndexOf ('\ test.something' ')) | Set-content file2.txt
In addition, you do not need trim but you are using the trimand so that you want to add it later. )
No comments:
Post a Comment