So I have a log file where I need to grab some information from the last line.
I run this command to grab the information from the last line of the file.
$Log = (Get-Content ".LogFile.log")[-1] PS C:$Log 715083793 451808326 2045 files, 337 folders
Trim the white space
$Data = $Log.Trim() PS C:$Log 715083793 451808326 2045 files, 337 folders
I need to grab this information, 2045 files, 337 folders. Using the following code I found online, I can get the necessary information.
PS C:$Data | ForEach-Object {[System.String]::Join(" ",$_.Split()[6..9]) } 2045 files, 337 folders
However, I don’t fully understand the code. I found the following Technet article, but it didn’t explain the $_Split, etc. https://blogs.technet.microsoft.com/heyscriptingguy/2014/07/16/join-me-in-a-few-string-methods-using-powershell/
Any help explaining the concepts would be appreciated, Thanks!
submitted by /u/Narusa
[link] [comments]
The post String Manipulation appeared first on How to Code .NET.