Suppose a particular command generates few files (I dont know the name of these files). I want to move those files into a new folder. How to do it in shell script?
i can’t use :
#!/bin/bash
mkdir newfolder
command
mv * newfolder
as the cwd contains lot of other files as well.
The first question is can you just run
commandwithnewfolderas the current directory to generate the files in the right place it begin with:Or if
commandis not in the path:If you can’t do this then you’ll need to capture lists of before and after files and compare. An inelegant way of doing this would be as follows: