Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
145 views
in Technique[技术] by (71.8m points)

Powershell - Find and Replace and show work

I have written this script to find "Procedure division" and replace it with a null value. It seems to work, so that's a good this.

What I need to add is the actual file names that were changed. I have 12K files and only around 800 or so are supposedly needing the change. I need to know what ones were actually changed. Is there a way to add the path and file name to be displayed in the below script?

$old = Read-Host 'PROCEDURE DIVISION.'
$new = Read-Host ''

Get-Children D:emp *.cbl -recurse | ForEach {
   (Get-Content $_ | ForEach {$_ -replace "$old", "$new"}) | Set-Content $_ 
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...