I want to search for a string in all .txt files in one folder and return the file namw. The folder can have sub folders and the string I Want to search should be passed as parameter. For ex I want all the file name and locations which have the string 0754665477
Asked
Active
Viewed 80 times
-2
-
1Show us what you have tried so far. – Eric Apr 01 '15 at 08:04
-
1Maybe you wanted to use Java instead of JavaScript. Didn't you? – Afzaal Ahmad Zeeshan Apr 01 '15 at 08:04
-
JavaScript is not Java. :v – Prashant Ghimire Apr 01 '15 at 08:05
-
Have a look here: http://stackoverflow.com/questions/24231617/search-for-a-string-from-a-text-file-in-java-script – d_z90 Apr 01 '15 at 08:05
-
@AfzaalAhmadZeeshan may be he is using node.js – Ashish Negi Apr 01 '15 at 08:05
-
You cannot read dics content by JavaScript, JavaScript is browser only, unless you are using some kind of nodeJS, but that will work as a Backend app. Cookies are the only exeption to this rule. Or you could doenload file content via Ajax... but that has little sence. – Beri Apr 01 '15 at 08:06
-
@AshishNegi, no matter what the case is. This question is not constructive and too low on information about the scenario too. I suggest he/she edit the post. – Afzaal Ahmad Zeeshan Apr 01 '15 at 08:07
-
@Beri that's not true. There's stuff like [the File System API](https://developer.mozilla.org/en-US/docs/WebGuide/API/File_System). And then there's things like [this](http://stackoverflow.com/a/1087257/238310). I still imagine he's using Java or node.js though. – Martijn Arts Apr 01 '15 at 08:08
-
Damn it, I must be out of date then:) Thanks for the news:) – Beri Apr 01 '15 at 08:09
-
@AfzaalAhmadZeeshan Totally agree with you on that. – Ashish Negi Apr 01 '15 at 08:15
-
@Vaish Take your time to read about how to ask questions on stackoverflow.. and it would be great if you can show what you have done till now.. Or keep doing this for future questions.. – Ashish Negi Apr 01 '15 at 08:24
1 Answers
0
How to read text file in JavaScript
here you can see how to read files with javascript.
Once you you have the text in a string variable, apply the .search method.