LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 07-06-2005, 01:33 PM   #1
mrobertson
Member
 
Registered: May 2005
Posts: 275

Rep: Reputation: 30
Printing a new file over the old file using cat


I have a script running that will read and print out this file. Right now I am using the following code:


Code:
#!/bin/sh
while sleep 1
      do
            cat camdata
done



And this code will print it out each time over and over again taking up multiple lines. The file is four lines of text. Is there anyway to just print the 4 lines and then when it comes time to print again....just print over the previous four lines so that there is always only 4 lines of text printed instead of 4 then 8 then 12 then 16.....etc?
 
Old 07-06-2005, 01:58 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Use redirection
Code:
#!/bin/sh
while sleep 1
      do
            cat camdata > camdatafile
done
But you have one second to se what's in the camdatafile
 
Old 07-06-2005, 02:16 PM   #3
ahh
Member
 
Registered: May 2004
Location: UK
Distribution: Gentoo
Posts: 293

Rep: Reputation: 31
I thnk the simplest solution is:-

Code:
#!/bin/sh
while sleep 1
      do
            clear
            cat camdata
done
 
Old 07-07-2005, 07:14 AM   #4
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
I tried adding clear like the last post suggested and got a "clear not found error." I also tried using the redirection approach suggested and got no output whatsoever. Is there any other way that this task could be done?
 
Old 07-07-2005, 10:18 AM   #5
ahh
Member
 
Registered: May 2004
Location: UK
Distribution: Gentoo
Posts: 293

Rep: Reputation: 31
Try typing "which clear" in your terminal to see if you have clear on your system - it should be there. If it is add the full path to your script.
Code:
#!/bin/sh
while sleep 1
      do
            /usr/bin/clear
            cat camdata
done
The redirection is writing the contents of camdata to camdatafile. You are basically making a copy of camdata.
 
  


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
trying to redirect text to a file to cat at later point. says file doesn't exist. dr_zayus69 Programming 1 10-02-2005 08:10 AM
how to cat a text file and save it as a variable mrobertson Programming 37 07-05-2005 08:20 AM
output to a file - cat? grep? Godsmacker777 Linux - Newbie 6 12-08-2004 10:06 AM
Cat with Binary File? Xaque208 Linux - General 1 12-06-2004 07:59 PM
how to delete file created as cat > --vp manikanth04 Linux - General 2 10-03-2004 06:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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