Powershell: Formating Select -Index array -


I am trying to create a good way to format the output of the parsed line, the rows I actually search for I have been able to parse some data

  # data from my file 2014-07-24 19:30:23 IP.ADD. Press #GET: 8888 / xxx / update / status / checkingfour updates - 80-1962.168.xx - 400 0 15 15   

So what I am doing, a large file for lines like this I'm actually searching for keywords of checkingfire updates, and then dividing "xxx" and "192.168.xx" by following the selection string string.

  Selection-string - Path $ File Location - Palette "Checking FourUp Updates" - All matches | % {$ _ -split "/"} | % {$ _-Split "-"} | Choose - Index2.7   

I will get an output with this:

  xxx1920.168.xx   

Item xxx is using and IP address of 1982.xx

I tried writing one-and-output and selected -Index's Failed to try to use the bar. Powerhail does not like this in a row ... any help would be greatly appreciated.

Using your sample data, it will appear that you get string array output. In my reply, I assign that string array to a variable and format the output using the -f format parameter.

  $ data = "2014-07-24 19:30: 23 IPAD.Press # GET /: 8888 / xxx / update / status / checkingfour updates - 80 - 19 2.168.xx - 400 0 15 "$ strings = $ data | Selection-string-porternia "checkingfour updates" - all matches% {$ _ -split "/"} | % {$ _-Split "-"} | Select - Index is using 2,7 "item {0} and we get output from IP address {1}" -f $ string [0], $ string [1]   

Gives: $ data = "2014-07-24 19:30:23 IPADD Press. # GET: 8888 / xxx / update / status / checkingfour updates - 80-1962.168 XX - 400 0 15 "$ strings = $ data | Selection-string-porternia "checkingfour updates" - all matches% {$ _ -split "/"} | % {$ _-Split "-"} | Select -index is using 2,7 items xxx and IP address 192.168.xx

While we do not have to use -f , then this Definitely clears more information to make the code easier to read.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -