Get-ChildItem -Path D:\SomeDir -File -Filter "App.properties"|Select-String "pushnotification.enabled=true" This is the final command you were looking for. Now take the final outcome of the previous objective and append this Select-String to make the command complete Get-ChildItem -Path D:\SomeDir -File -Filter "App.properties"|Select-String "pushnotification.enabled=true" PowerShell gives us an another command named Select-String to replace the linux xargs -grep part. Windows Equivalent to xargs -grep Command Now we got the files now we need to traverse through the resulted files and search for the string that we are searching for, Thats our Second Objective or Second Part of the puzzle. Task 2: Look for a String in the matching/resulted files If not, Here is the command Get-ChildItem -Path D:\SomeDir -File -Filter "App.properties" Now I hope you might have got a good grip on the Get-ChildItem command and have already figured out the first part of the puzzle or completed the first objective. There are more I can continue to list but I already feel like I am sidetracked. Ls -lrt GithubRepo|awk '' (or) ls -a|sort Print only the names of Files and Directories Recursive Listing including All Sub Directories Get-ChildItem -Path D:\GithubRepo\ -Filter "*.properties" -Recurse -File Get-ChildItem -Path D:\somedir\ -Directoryįind GithubRepo -type f -name "*.properties" Simple List with Reverse Sort by Date In Present Working Directory Note*: A Period/Dot (.) in the command represents the present working directory Purpose Some of Linux Commands and their Windows Equivalents with Get-ChildItem are listed below. If you read through the Syntax of the command itself you could understand what it offers. Yes this childish Get-ChildItem is the game changer and provides a lot of features. Windows Powershell is giving you a powerful alternative for the Linux find and ls I should shake your hand cause thats exactly what I thought before being introduced to the Powershell commands If you are thinking of Dir command of Windows Command Prompt. Here in our case we need to find the files with the name "App.properties"īefore going straight into our requirement, Let me give some background and brief on how we are going to do it. Now our first objective is to find the files matching our criteria. Task 1: Find the File or Files in a Specific Directory
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |