LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-27-2005, 02:37 AM   #1
goral.j
LQ Newbie
 
Registered: Jan 2005
Posts: 4

Rep: Reputation: 0
shell script output redirection


I am having a lot of trouble figuring out how to output the contents of a command to a file and also having it appear within the terminal. All the standard redirection I know of, such as ping google.com > output.out, will simply give the impression that the computer has locked up while it prints to file.

Is there anyway to have the output printed within the terminal and to the file simultaneously?

Thanks in advance,

Jeff
 
Old 01-27-2005, 02:39 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
You want the tee command (man tee)

For example:
Code:
date | tee somefile.txt
You'll see the output of the date command on the screen, and the same information will be written to somefile.txt.
 
Old 01-27-2005, 02:46 AM   #3
goral.j
LQ Newbie
 
Registered: Jan 2005
Posts: 4

Original Poster
Rep: Reputation: 0
You are awesome. Thank you very much.
 
Old 01-27-2005, 06:34 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,298

Rep: Reputation: 175Reputation: 175
Also:
tee -a if you want to append a file
and not clobber it.
 
  


Reply


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
How do I make PHP display output from my shell script? farmerjoe Programming 2 04-03-2005 02:15 PM
Shell Script (adding a prefix to output lines) rheza Programming 3 01-04-2005 02:18 PM
Shell Script for Gzipping with date output Junior41180 Programming 1 10-16-2004 07:39 AM
bash:output file names from shell script to vi sickboy Linux - Newbie 6 10-14-2004 04:40 AM
I/O redirection in a shell script gladeiator Programming 1 11-27-2003 02:35 PM


All times are GMT -5. The time now is 04:06 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration