How to get and copy a too long output completely in terminal?
Solution 1
I know in the xfce4-terminal there is a option to increase the number of lines shown:
For ubuntu Terminal
Aside from that there is what @Zelda64fan said.
Solution 2
You could send the output to a file: command > file.txt
(where command
is the command you want to run and file.txt
is the file you want to save it to) and then view it with gedit file.txt
.
Solution 3
Use xclip
cat long.output | xclip -sel clip
If not installed you can do
sudo apt-get install xclip
Solution 4
If you don't need the entire output, you could pipe it through less: command | less
. This would also save the bother of having to delete the file once you've reviewed the output.
Solution 5
Save console output into a file:
tee
command
tee command - read from standard input and write to standard output and files.
It automatically creates file and save, all the output of cmd ps -ax
into a file named as processes_info
in the same folder from where the cmd has run.
user@admin:~$ ps -ax | tee processes_info
script
command
script command - make typescript of terminal session.
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 CTRLD is typed.)
user@admin:~$ script -c "ps ax" processes_info.txt
it starts the script;
creates the file
processes_info.txt
;stores the console output into the file;
end (close) the script.
Other example:
script -c 'echo "Hello, World!"' hello.txt
Related videos on Youtube
James Gayle
Updated on September 18, 2022Comments
-
James Gayle over 1 year
i have a button on my index / home page:
<a href="action.php">click</a>
When this is clicked it runs my mysql query in action.php and after i have run my query i want to send out an email. So after the query has executed i include my send_email.php file:
$query = "update table1 SET action = '1' WHERE something = something"; $result = mysql_query($query); include 'send email.php'
in send_email.php i have:
<?php date_default_timezone_set("Europe/London"); // multiple recipients $to = "[email protected]"; // // subject $subject = 'New Supplier Set-Up - Hewden Portal'; // message $message = include '../../assets/email/index.php'; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: Mark <[email protected]>'. "\r\n"; $headers .= 'From: Hewden Portal <[email protected]>' . "\r\n"; $headers .= "Cc: mark.o'[email protected]" . "\r\n"; // Mail it mail($to, $subject, $message, $headers); echo "Updated data successfully\n"; ?>
As you can see I am trying to include my email html as a seperate php file stored in assets/email/index.php. i am trying to do it this way so the email can be easily edited at a later date.
However using this method doesnt work. The email is sent but its blank without any HTML. Also after the query has executed it takes you to the email html page/index.php.
an illustration of my email html / index.php:
<html> <Body> <p>This is my email template</p> <p>More Text here bla bla</p> <style> Some CSS </style> </body> </html>
Why is this? when it should be echoing 'Updated data Succesfully' and be sending the email with html?
Can someone please show me what i am doing wrong? Thanks
-
Eliah Kagan almost 10 yearsRelated (but not a duplicate): How can I capture text from a specific terminal and redirect it to a log file while simultaneously working?
-
-
22lk94k943 only almost 11 years+1 Pipe and
tee
are not optimal as dont work on few cases like take in aHROOT 3NVIORTNM3NT
-
Sparhawk about 10 years
less
output is pretty hard to copy. -
James Gayle about 9 yearsyes thats correct, how would i structure this using file_get_contents please as this is something i have never used before, thanks
-
Richie about 9 yearsIt's well covered in the documentation. Click the provided link above
-
James Gayle about 9 yearsthanks i have done what you suggested using $message = file_get_contents('../../assets/email/index.php'); however now the email will not send
-
Richie about 9 yearsLet me see what's in that file?
-
Sergiy Kolodyazhnyy over 7 yearsThis one is my personal favorite for GUI terminals. With TTY it won't work, unfortunately, only redirection to a file will help there
-
Jignesh Gohel about 6 years
script -c "rails runner -e development lib/scripts/my_script.rb" report.txt
helped me to capture a Rails runner script's very-very long output easily to a file. I tried using redirecting to a file but it got written only at the end of script. That didn't helped me because I had few interactive commands in my script. Then I used justscript
on my and then ran therails runner
in script session but it didn't wrote everything. Then I found thisscript -c "runner command here" output_file
and it saved all the output as was desired. This was on Ubuntu 14.04 LTS