I have an executable file in a directory, when I run that file (using ./file) I get an output file (.out), which are saved on the same directory of the executable file. I want this output to be saved in a subdirectory of the mentioned directory. What command/flag should I use?
>Solution :
Two possibilities:
-
IF you redirect the output to file
outyourself:cd directory || exit ./file >.outthen you can do:
cd directory || exit ./file >subdir/.out -
IF the
fileexecutable creates its own.outfile:cd directory || exit ./filethe .out file is created by the executable, and you cannot change it (ex. it is not a script), move the file yourself:
cd directory || exit ./file && mv .out subdir
You could wrap this into a script, call it myfile:
#!/bin/bash
cd directory || exit
./file
mv .out subdir/.out