Home > Enterprise >  SSH Command to save output in specific directory
SSH Command to save output in specific directory

Time:04-11

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?

CodePudding user response:

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
  • Related