Q:

· 1 min read
Q:

https://1win-bet-azerbaycan.com/

Powershell script to return list of all files containing a specific string?

What is the simplest way to get a list of all files in a directory containing a specific string?
Example: I have a directory (in a Git repo) that contains files of the form
a.txt
b.txt
hello.txt
c.xml
Doe John

I want to run a Powershell script that returns the names of all files in this directory containing the string "Doe".

A:

DirectoryInfo dir = new DirectoryInfo(path);
DirectoryInfo[] subDirs = dir.GetDirectories("*", SearchOption.AllDirectories);
var files = subDirs.Where(x=>x.Name.EndsWith(".txt"));

Edit: after discussion of your comments below I have updated the code. I've also added a proper error-handling statement (option Set-StrictMode -Version 2) to the script. To use it you'll have to add a reference to the Microsoft Scripting Runtime library and set the current directory.

A:

If you're using Windows PowerShell:
dir |? $_.Name -match 'John'

People's Platform

The People’s Platform was a political initiative of The People's Movement for Socialism (MAS) intended to be the programmatic programme of the MAS for the 2007 Venezuelan National Assembly election.

According to the Marea Socialista website, the programme's objective was "to form the basis of a democratic government for Venezuela". The objective of this program was listed as the promotion of socialist policies.

The program was released on May 28, 2007.

The platform is divided into five parts: the first is called “This is the Truth”; the second is called “This is the Way”; the third is called “This is the Goal”; the fourth is called “This is Our Life”; and the last is called “This is the Spirit”.

References


Category:Political party programmes
Category:2007 documents
Category:2007 in Venezuela
Category:2007 in politicsThe "Game of Thrones" cast had a massive conga