If I want to list the files of a directory and save the results in a res.txt
I can run the command
ls -l > res.txt
Now I would like to do the same in a process spawned from the main process of Node.
I have tried naively this
spawn(
'ls',
['-l', '>', 'res.txt'],
);
but does not work. Is there any way to achieve what i want?