How can I redirect output files to a specific directory/folder

5,160

If myExe is in ./ and it defaults to writing to 4 files in ./ but you instead want those 4 files in /myfolder then you can do:

(cd /myfolder && "$OLDPWD/myExe" params)

...which will still write those 4 files to ./ but change the value of ./ to /myfolder for only the length of time it takes to for ./myExe to write them.

Share:
5,160

Related videos on Youtube

user677101
Author by

user677101

Updated on September 18, 2022

Comments

  • user677101
    user677101 almost 2 years

    Suppose I have an executable in Unix. Suppose the name of the .exe file is myExe and it takes two parameters. I did not create this executable, this is a freely available one. myExe generates 4 different files. I want to direct all its output files to a specific folder. How can I do it in Unix command? So I want something like this:

    ./myExe parameter1 parameter2  "output to /myfolder "
    

    ​So now the four files produced by myExe will be directed to myfolder. ​