To give you the best experience, this site uses cookies. Continuing to use 9bis.net means you agree to our use of cookies.
 

 

exec ( en )

Last modification : 2013/01/26 19:16

exec is the internal command to redirect the standard input and output stream from or to a file.
  • Standard output stream
To redirect standard output use > parameter. Beware, in interactive mode even the prompt is sent to new standard output.
In the example below try to type print 123 and exec > just after the redirection.
msh> exec >1.txt
msh> cat 1.txt
123
The simple exec > command switch the standard output back to his initial state (i.e. the screen).
To add the output to an existing file (and not replacing it) use exec >>.
msh> exec >>1.txt
msh> cat 1.txt
123
456

  • Error output stream
The syntax is exactly the same for the error stream, but with the 2> parameter.
msh> exec 2>2.txt
msh> exec 2>>3.txt
msh> exec 2>

  • Standard input stream
exec < is used to redefine the standard input stream.