Task 1: Find the File or Files in a Specific Directory Windows Equivalent to xargs -grep Command.Task 2: Look for a String in the matching/resulted files.Windows Equivalent to Find or ls Command.Task 1: Find the File or Files in a Specific Directory.To know, How this command has been created and know how it is working. In Windows, The same can be acheived with the following powershell command Get-ChildItem -Path D:\SomeDir -File -Filter "App.properties"|Select-String "pushnotification.enabled=true" In Linux we would have been able to do the same with the following command find /somedir -type f -name "App.properties" |xargs grep -i "pushnotification.enabled=true" Look for a String in that matching/resulted files.Find the file or Files in a Specific directory.Now, We can decouple the requirement into two different sub tasks This article is about how to use Windows PowerShell find command to find string in file. I would have simply used something like Git Bash or someother Bash emulators for windows but I wanted to give it a chance to PowerShell and I was really impressed cause it is really powerful than I thought it was.Įnough of Bla Bla Bla. I was looking for a file named "App.properties" and wanted to look for a specific property or String and see if it is enabled or not. I am a Linux user and If you would have searched for "Windows Find command with Xargs" to come here then you are too.īeing used to the Linux commands like Find, Grep, Xargs I was really finding it hard when I had a requirement like given below. ( more like what we do with xargs in Linux) If you are here, Then you might have had a similar requirement I had, which is to find a specific file across multiple directories and to grep or Search for a string present in that file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |