Best posts made by Guyr989
Latest posts made by Guyr989
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; var words_in_file = process.argv;
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?