Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SSH Command to save output in specific directory

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Two possibilities:

  • IF you redirect the output to file out yourself:

    cd directory || exit
    ./file >.out
    

    then you can do:

    cd directory || exit
    ./file >subdir/.out
    
  • IF the file executable creates its own .out file:

    cd directory || exit
    ./file
    

    the .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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading