-   Linux - Newbie (
-   -   How to Copy Terminal Output to a File (

SkM007 04-20-2012 03:05 AM

How to Copy Terminal Output to a File
I am using backtrack & a particular s/w (fierce) generates a lot of output on the terminal. I actually want to get this entire output to a txt file but i don't know how to do it. I know i can redirect the output to a file but i dn't want to do it for every command. also the output is very large (varies from 50 - 1000 lines based on the command) that most of the time i can't do copy-paste thing, as earlier commands are not visible (i hope u understood)
if u'll use putty or HT in windows, it has options by which all the activities on the terminal can be saved in txt file.

is there anything i can do???

Satyaveer Arya 04-20-2012 07:03 AM

If you're using the terminal then the only option is to direct the output of commands in files.

ratotopi 04-20-2012 11:39 AM

use the tee command eg
ls -l /root | tee /tmp/rootls
this will out put your command to screen and files but if you want to create file only then do
ls -l /root >> /tmp/rootls

pan64 04-20-2012 12:01 PM

maybe the script command is what you are looking for

jefro 04-20-2012 04:49 PM

Use of fierce.

"It provides different techniques to gather information about your victim."

unkn(0)wn 04-20-2012 04:53 PM

just use ">" between output command and desired filename.

eg. if you want output of a.out in file output.txt, use

./a.out > output.txt
and to append use ">>"

hope it helps!

SkM007 04-21-2012 05:43 AM

Ok, then i m left with the option of redirecting & appending the output :(

anyway, thanks everyone :) 01-01-2016 03:55 PM

Save console output in a file:
By-the-way, it was an informative session for me and basically from this, what I learned is given as follow:

A) "tee" command
user@admin:~ $ ps -ax >> processes_info
Saves, all the output of cmd "ps -ax" into a file named as "processes_info" in "tmp" folder. It automatically creates file "processes_info"

user@admin:~$ ps -ax | tee processes_info
It's do the same as above but "tee" cmd also display the output on the console simultaneously.

B) "script" command
user@admin:~$ script my_console_output.txt
This creates a file named as "my_console_output.txt" and will open a subshell and records all information through this session.
After this, script get started and whatever the console output, it will get stored in the file "my_console_output.txt";

unless and until the script ends when the forked shell exits. (e.g., when the user types "exit" or when "CTRL-D" is typed.)

user@admin:~$ script -c "ps ax" processes_info.txt
It starts the script; creates the file "processes_info.txt"; store console output into file; end the script.

Other example:
script -c 'echo "Hello, World!"' hello.txt

Thanks & Regards

sgosnell 01-02-2016 10:31 PM

Using your email address as a forum ID is a bad idea. 01-03-2016 10:06 AM

Kindly suggest me how to change this

Originally Posted by sgosnell (Post 5472350)
Using your email address as a forum ID is a bad idea.

Hello Sir,

I tried to alter it, but don't find the exact location. Could you help in this.
Kindly suggest me how to change this.

sgosnell 01-03-2016 04:17 PM

Delete the account, and make a new one. There may be other ways, but that's probably the easiest.

All times are GMT -5. The time now is 01:36 AM.