Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 01-27-2005, 01:37 AM   #1
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 > 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,

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

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

For example:
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, 01:46 AM   #3
LQ Newbie
Registered: Jan 2005
Posts: 4

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

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


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 01:15 PM
Shell Script (adding a prefix to output lines) rheza Programming 3 01-04-2005 01:18 PM
Shell Script for Gzipping with date output Junior41180 Programming 1 10-16-2004 06:39 AM
bash:output file names from shell script to vi sickboy Linux - Newbie 6 10-14-2004 03:40 AM
I/O redirection in a shell script gladeiator Programming 1 11-27-2003 01:35 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:17 AM.

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