visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
262 experts, 1140 registered users, 1615 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

We now celebrate our 5 years of existence and break our frequentation records... Here are the stats of those 5 years.

Operating Systems :: Unix :: output to screen


By: roe1and Great Britain  Date: 29/04/2008 11:17:28  English  Points: 20 Status: Answered
Quality : Excellent
if i do:

du -ak

it prints a list of all the files in a directory and the size of those files.
if i do this:

du -ak > list.txt

the output goes straight into a text file called list.txt

my question is: can i output to both screen and textfile simultaneously?
By: VGR Date: 30/04/2008 22:38:33 English  Type : Comment
okkkkk

first, you could write a two lines shell script (the second being "cat list.txt").
then, you could try piping shell commands in stead of redirecting output
you could probably even pipe your above command to "cat", on one single line

those were cheap ideas ;-)

personally, I would write a shell script, it'll be more portable than an obscure single liner.

sorry, I don't have a unix system under hand and can't test.
By: roe1and Date: 01/05/2008 10:39:02 English  Type : Comment
thanks for the input. i'm running a huge shell script and wanted to monitor the progress onscreen. i've decided though that as long as there are no error messages i should be ok!
By: VGR Date: 02/05/2008 09:50:27 English  Type : Answer
well... as for me, I don't code any more shell scripts in any OS-level C-like language (bash for instance) mainly because they're incompatible between each other (and very limited, you realize this now ;-) and neither do I code windows-specific Win API programs. May-be you could do like me. I do everything in PHP in CLI mode. It requires only one or two files to be copied to the executables path, and voila, it works. A bit like perl (on windaube, you copy perl.exe in your path and you can run perl scripts ; it's the same for the same footprint for PHP, but PHP is better suited for all-around tasks)

in CLI mode, you can force output by flush()ing (or fflush()ing if to a file), you can monitor external calls for completion, you natively have access to databases... and it's faaaast.

monitoring a huge shell script from an other shell script is doomed in my humble opinion.

good luck
By: roe1and Date: 02/05/2008 11:39:52 English  Type : Comment
i agree. i'll try to convert everything to php next week. i'll let you know how far i get. i might need some clarification on one or two points.

thanks again!

Do register to be able to answer

 Add This Article To:
 del.icio.usDel.icio.us  diggDigg  googleGoogle  spurlSpurl
 blinkBlink  wongWong  simpySimpy  yahooY! MyWeb 
EContact
browser fav
page generated in 4548.007970 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page