8/3/2023 0 Comments Windows grep equvalentHere is an example that searches for the string app in a file called myfile.txt. This works with "uniq mytextfile" as well as "cat mytextfile | uniq" as all input and arguments are simply passed to the sort command. The findstr command is the Windows equivalent of the Unix grep command. Rem "set" needs to be done without delayed expansion ![]() Save this in a batch file "uniq.cmd" somewhere in your %path% can find it (e.g. ![]() You can easily write the command "uniq" by yourself. Since these packages also contain cat, sort and uniq - your workflow should be mostly identical, and cat file.txt |sort | uniq should work mostly identically Solution 3 You have to pipe multiple commands together one command to transverse the directories, and one command to look for the pattern within each file found. If you are on Win-7, then there is powershell, with select-string. With the introduction of PowerShell, Windows has given us the grep functionality albeit with a much less finesse than the Linux equivalent. If you don't want to install anything and is on Win XP, try findstr, although it can't do 'orring'. If you need only grep, then there is GnuWin32. ![]() No cygwin required though for the latter you need to look in /usr/bin Well you can have cygwin on Windows so then you have bash, grep, etc. I personally use the variation from GOW but git for windows has a significantly newer version. There's ports of uniq that work identically to the gnu/coreutils versions. Of course, owing to presence of aliases in PowerShell, you can also write: type file.txt | sort -uniqueĪdditionally, there is an undocumented /unique switch in sort.exe of Windows 10, so, this should work in Command Prompt: type file.txt | sort /unique The Sort-Object cmdlet in PowerShell supports a -Unique switch that does the same thing as uniq: Get-Content file.txt | Sort-Object -unique
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |