powershell - Read line-by-line file and split values -


i need read txt file composed follow:

      aa=1000,aa=320009#999999        aa=1011,aa=320303#111111 

for each readed line need split "#" @ first turn

 $test[0] = aa=1000,aa=320009 , $test[1]=999999 

and @ second turn

 $test[0] = aa=1000,aa=320003   $test[1]= 1111111 

i have problems understand how use get-content or it.

# basically, get-content return array of strings such below: # $tests = get-content "c:\myfile\path\mytests.txt"  $tests = @(     "aa=1000,aa=320009#999999",     "aa=1011,aa=320303#111111" )  $tests | %{ $test = $_ -split '#'; write-host $test[0]; write-host $test[1] } 

the line above equivalent to:

$tests | foreach {   $test = $_ -split '#'   write-host $test[0]   write-host $test[1] } 

meaning each line of $tests (each line being materialized $_, 1 split on '#' (which produces array used in write-host statements)


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -