Node.js & cmd Filter file by extension and text in file
-
I need to process/filter files by their extension and text inside the file.
It must be via the command-line.This is the cmd line:
C:\myFolder> node search.js [extension][any text]
I only managed to isolate the 2 strings:var file_extension = process.argv[2]; var words_in_file = process.argv[3];
But now I need to build a filter that takes 2 args: 'file_extension' & 'words_in_file'
returns(display) a list of all files(full-path) ending with this extension (e.g txt/js/html etc..)
and containing the text of the second argument.
including in the sub folders files(if any).1.How do I get only the files with the extension that was passed?(absolut path) 2.How do I read the file content and compare it to the text that was passed? 3.How to display it all in the cmd?
Thank you.
-
It looks like you've misunderstood the purpose of this forum. This is the community forum for the Node.js-based forum software known as NodeBB.
For general Node help, you might want to try StackOverflow, SpeakJS on Discord, or /r/node and /r/javascript on Reddit.