Go Job Hunting at the LQ Job Marketplace
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-03-2009, 09:43 AM   #1
sumeet inani
Registered: Oct 2008
Posts: 885
Blog Entries: 26

Rep: Reputation: 48
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?
Old 07-03-2009, 10:25 AM   #2
Registered: Jan 2009
Location: Dhahran, Saudi Arabia
Distribution: RHEL 5
Posts: 42

Rep: Reputation: 17
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

date > log.txt
tar $1 $2
date >> log.txt

do man tar, you could find something better
Old 07-03-2009, 10:33 AM   #3
Registered: Jul 2009
Posts: 50

Rep: Reputation: 8
The output of any command can be redirected from standard output to a file using > or >>
$ 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.
Old 07-03-2009, 10:34 AM   #4
Senior Member
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 315Reputation: 315Reputation: 315Reputation: 315
You can pretty well use time command also to estimate the time.
time command
It will show time it takes to completing the command.
Old 07-03-2009, 10:36 AM   #5
Registered: Feb 2009
Distribution: CentOS 5, Gentoo, FreeBSD, Fedora, Mint, Slackware64
Posts: 205

Rep: Reputation: 46
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in redirecting the output of command in gnome-terminal satya_seth Linux - Newbie 1 05-23-2009 06:05 AM
Automatically append another piped command to issued command in bash amateen Programming 1 05-07-2009 06:36 AM
Script or Terminal command to switch audio output? jjsonp Linux - Software 0 01-26-2008 01:10 PM
How to see all output of command in terminal pilotgi SUSE / openSUSE 2 06-27-2007 09:03 PM
shell scipting: append output of a command to a variable jonhewer Linux - Newbie 10 08-24-2005 05:42 AM

All times are GMT -5. The time now is 05:14 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration