简体   繁体   中英

how to put single quotes and a coma to a string in powershell

I am trying to put singles quotes with comma at the end of the line but can't think how i can achieve this. So far i am only able to put single quote with comma at the end , but i would like put put single quote at the beginning of the line as well. Can somebody please help

I would like to achieve 'test1', but at the moment i can only do test1',

#Define Variables
$a = 'P:\Powershell practice\Movefolder\LD.txt'
$b = get-content $a

#Define Functions
function append-text { 
 process{
 foreach-object {$_ + "',"}
} 
}

#Process Code
$b | append-text

This?

function append-text { 
process{
foreach-object {"'" + $_ + "',"}
} 
}

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