redirecting multiple commands into a single file

L

liadsh

Guest
Hey,

is it possible to redirect multiple command into the same file?
let me clarify - let's say that i want to redirect the output of "ifconfig -a" and "netstat" into a file called txt.txt
i know that it's possible by running # ifconfig -a > txt.txt ; netstat >> txt.txt

just wanted to know if it's possible to do this using only one redirect.
thanks.
 


This should work:
Code:
(ifconfig -a; netstat) > txt.txt
 
No worries, glad to have helped.
BTW as an afterthought:
If you want to be able to see the output from the commands on the terminal AND write the output to a file you can pipe the output from the commands to tee.
Code:
(ifconfig -a; netstat) | tee txt.txt
 
No worries, glad to have helped.
BTW as an afterthought:
If you want to be able to see the output from the commands on the terminal AND write the output to a file you can pipe the output from the commands to tee.
Code:
(ifconfig -a; netstat) | tee txt.txt
I think this is a cleaner solution.
 

Members online


Top