Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
07-03-2009, 09:43 AM
|
#1
|
Member
Registered: Oct 2008
Posts: 908
Rep:
|
append command output to file by giving command in terminal
Hi,I am using openSUSE 10.3.
When I install software from tarball then to record time required I send output of date to beg.txt(when installation begins) and end.txt (when installation finishes).
How can I append output of date to a file so I don't need two files?
|
|
|
07-03-2009, 10:25 AM
|
#2
|
Member
Registered: Jan 2009
Location: Dhahran, Saudi Arabia
Distribution: RHEL 5
Posts: 42
Rep:
|
ummm I would do that with a small script. The tar command will be invoked from within the script. Let's the tar command arguments are passed to the script in $1 and tarball in $2
so
#!/bin/ksh
date > log.txt
tar $1 $2
date >> log.txt
do man tar, you could find something better
|
|
|
07-03-2009, 10:33 AM
|
#3
|
Member
Registered: Jul 2009
Posts: 50
Rep:
|
The output of any command can be redirected from standard output to a file using > or >>
example
$ ls > listings.txt write directory listing into a new file called listing.txt
$ date >> log.txt append the current date/time to the file log.txt
note that > creates a new file, >> appends to an existing one.
|
|
|
07-03-2009, 10:34 AM
|
#4
|
Senior Member
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524
|
You can pretty well use time command also to estimate the time.
time command
It will show time it takes to completing the command.
|
|
|
07-03-2009, 10:36 AM
|
#5
|
Member
Registered: Feb 2009
Distribution: Debian, CentOS 5, Gentoo, FreeBSD, Fedora, Mint, Slackware64
Posts: 208
Rep:
|
Code:
echo "start time: `date`" > /tmp/time.txt
<do stuff>
echo "end time: `date`" >> /tmp/time.txt
The quotes around date are backquotes, not the normal quotes. The ">>"means append.
Last edited by nuwen52; 07-03-2009 at 10:40 AM.
|
|
|
All times are GMT -5. The time now is 06:01 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|