Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell command to set a variable from the last value of the function

$
0
0

Hello everyone.

I'm trying to find out how do I set a variable from the last line of the result of a function.

Example:

I use CAT to view a TXT file that contains 5 lines, I want to set a variable with the value of the 5th line (if the line it's not blank).

In batch I would just use the 'for /F "tokens=*" %%a in (file.txt) do set var=%%a'. I'm looking for something similiar to this.

Any tips?

Thanks in advance.


Att, Paulo Rocha


Viewing all articles
Browse latest Browse all 15028

Trending Articles