简体   繁体   中英

How to use a Where-Object on a Csv and get the output without header

I have a csv file which looks like below

Name
Jonh
Jimmy
Sunny
Dany

So to get compare the list of names in CSV file with another name i used the below command

$csv = $csv | where {$_.Name -ceq "Jimmy"}

I am getting output as below

Name
------
Jimmy

can I have just just have the output as

Jimmy 

Instead of

Name
-------
Jimmy

EDIT : Formatting

You should use:

$csv = $csv | where {$_.Name -ceq "Jimmy"} | Select-Object -ExpandProperty Name

I believe in later versions of powershell you can simply call a property name from the results, like so:

$csv = ($csv | where {$_.Name -ceq "Jimmy"}).Name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM