LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


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

Rep: Reputation: 49
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
geek.ksa
Member
 
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
so

#!/bin/ksh
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
mericet
Member
 
Registered: Jul 2009
Posts: 50

Rep: Reputation: 8
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.
 
Old 07-03-2009, 10:34 AM   #4
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
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
nuwen52
Member
 
Registered: Feb 2009
Distribution: Debian, CentOS 5, Gentoo, FreeBSD, Fedora, Mint, Slackware64
Posts: 208

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


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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