
You want to search for a specific word text from a document. Let say, you have 5 notepad files and you want to locate the text word of “ayam” from all the 5 notepad files.
This is really useful if you want to find any duplicate contents from your documents. The following steps below are based on Windows PowerShell.
Launch the Windows PowerShell and go the target directory. The example below shows that we have 5 text files, DEFAULT1.txt – DEFAULT5.txt.
> cd \ITsiti
> dir
Directory: \\ITsiti
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 4/05/2018 7:12 AM 709 DEFAULT1.txt
-a--- 4/05/2018 10:22 AM 866 DEFAULT2.txt
-a--- 7/05/2018 1:21 PM 893 DEFAULT3.txt
-a--- 7/05/2018 2:15 PM 954 DEFAULT4.txt
-a--- 7/05/2018 2:17 PM 1025 DEFAULT5.txt
Use the following command to locate the text word you needed. In below example, we want to find the “ayam” word from DEFAULT* text files. The DEFAULT* text files are reside in the ITsiti folder.
> Select-String -Pattern "ayam" -path \ITsiti\*
The output shows that there are 3 files having “ayam” word inside.
- DEFAULT1.txt is having the word ayam_kampung at line 18.
- DEFAULT2.txt is having the word ayam at line 10.
- DEFAULT5.txt is having the word ayam_bandar at line 27.
\ITsiti\DEFAULT1.txt:18:ayam_kampung
\ITsiti\DEFAULT2.txt:10:ayam
\ITsiti\DEFAULT5.txt:27:ayam_bandar