Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to log all the command output to one single file in bash scripting [duplicate]

Tags:

bash

In gnu/Linux i want to log all the command output to one particular file. Say in terminal,i am typing

echo "Hi this is a dude"

It should print in the file name specified earlier without using the redirection in every command.

like image 384
Tingrammer Avatar asked Dec 09 '25 23:12

Tingrammer


1 Answers

$ script x1
Script started, file is x1
$ echo "Hi this is a dude"
Hi this is a dude
$ echo "done"
done
$ exit
exit
Script done, file is x1

Then, the contents of file x1 are:

Script started on Thu Jun 13 14:51:29 2013
$ echo "Hi this is a dude"
Hi this is a dude
$ echo "done"
done
$ exit
exit

Script done on Thu Jun 13 14:51:52 2013

You can easily edit out your own commands and start/end lines using basic shell scripting (grep -v, especially if your Unix prompt has a distinctive substring pattern)

like image 97
DVK Avatar answered Dec 11 '25 23:12

DVK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!