Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

Compare entries from a textfile with keys in hash-table

$
0
0

Hey All,

I’m in need of a little powershell help 😉

I have a hash-table setup with keys/values like this :

key1 = value1

key2 = value2

key3 = value3

On the other hand, I import a text-file (can be any type of content) into a variable using this : $inputtextfile = get-content “mytextfle.txt”

My problem is the following…

I need to compare each line in that text-file with the keys in my hashtable, and if a match is found, take some action.

The problem is that the lines in the textfile might have leading or trailing spaces.

eg :

line1

line2 with more content

<leading spaces>key1

line 3

key2<trailing spaces>

I hope that It’s clear what I need to achieve ?

submitted by /u/TomDegreef
[link] [comments]

The post Compare entries from a textfile with keys in hash-table appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Latest Images

Trending Articles



Latest Images