Results 1 to 2 of 2
When I execute the following command from the linux command line I get the output I want to the screen
top –d 5 –b | grep –E “^Mem|average”
when I ...
- 04-21-2011 #1Just Joined!
- Join Date
- Apr 2011
- Posts
- 1
File redirection does not work Bizzare
When I execute the following command from the linux command line I get the output I want to the screen
top –d 5 –b | grep –E “^Mem|average”
when I redirect this to a file it doesn’t work ( zero length file ) Any ideas?
top -d 5 -b | grep -E "^Mem|average" > top.out
when I echo something to a file then that works
echo hello > top. out
I am using a bash shell on a virtual redhat linux box.
- 04-21-2011 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
You may need to wait awhile before you get results in top.out since you are specifying that top runs continuously at 5 second intervals. The system caches the output before it will pass it to grep/egrep. If you were to do this:
top -n 1 -b | grep -E "^Mem|average" >top.out
you will get results immediately. With the command you specified, it will take a number of seconds (or as much as a minute or so) before the output buffers get flushed and grep can process it to the output file.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote