Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 12-13-2003, 12:26 PM   #1
Registered: Aug 2003
Location: Belgium
Distribution: Slackware 10.2 + FRG + 2.6.15
Posts: 232

Rep: Reputation: 30
Bash: show on terminal and save to file

Hi everyone,

As you can see I am looking for a command / method to save the output to a file and getting the changes on the screen, real-time.

I have tried several cats and pipes, I can't find a solution.


Old 12-13-2003, 12:44 PM   #2
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Old 12-13-2003, 12:53 PM   #3
Registered: Jun 2003
Location: Canada,Ontario
Distribution: Debian and Gentoo
Posts: 135

Rep: Reputation: 15
save what output to a file?
tail <file> -f ( will print the output of <file> in realtime to standard output )

Last edited by dmx9595; 12-13-2003 at 12:54 PM.
Old 12-13-2003, 01:02 PM   #4
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
You can have some fun with grep!

For example.....
ifconfig | grep "" > ip.txt will save the entire output of ifconfig

ifconfig | grep "" | cut -d: -f2 | cut -dB -f1 > ip.txt This strips it down a bit.

ifconfig eth0 | grep --max-count=1 'inet' | cut -d: -f2 | cut -dB -f1 > ip.txt This really " cuts " things down and only saves the ip address of eth0

Edit: To more properly anwer the question of show on terminal and save to file you can use the command twice and separated by the && operator.

For example..
dmesg && dmesg |grep "" > test.txt This will output to the screen and save to the file also.

Last edited by homey; 12-13-2003 at 02:02 PM.
Old 12-13-2003, 01:59 PM   #5
Registered: Aug 2002
Posts: 14,649

Rep: Reputation: 1458Reputation: 1458Reputation: 1458Reputation: 1458Reputation: 1458Reputation: 1458Reputation: 1458Reputation: 1458Reputation: 1458Reputation: 1458
BTW To save output from a console command to a file. But the redirected text will not be displayed on the monitor at the same time.

> file.txt (creates a new file or overwrites existing file)
>> file.txt (appends to existing file or creates if it doesn't exist)
Old 12-13-2003, 04:49 PM   #6
Registered: Aug 2003
Location: Belgium
Distribution: Slackware 10.2 + FRG + 2.6.15
Posts: 232

Original Poster
Rep: Reputation: 30
thanx for the tee command.

very helpful. really thank you.



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
Linuxconf didn't show up when i typed in the terminal and problems with samba ineth Red Hat 1 10-22-2005 04:44 PM
how to show input and output of a program on the terminal divin Linux - Software 1 03-25-2005 12:19 AM
configuring terminal so not to show full path harshnoise SUSE / openSUSE 2 02-26-2005 07:42 AM
Terminal size (How to save??) sevvy8 Linux - Software 2 08-16-2004 06:21 PM
show all terminal typed commands joulupukki Linux - Newbie 6 05-10-2004 04:42 AM

All times are GMT -5. The time now is 09:10 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