Output of until to file versus stdout


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 5 Days Ago
Output of until to file versus stdout

Why does this until false; do history | head -5; done
result in a stdout infinite loop, yet until false; do history | head -5 > hist5; done
only writes it once to file hist5? Furthermore, I can hear the hard drive working on the 2nd command until I end the process, but the history | head -5 is only written once.
# 2  
Old 5 Days Ago
Quote:
Originally Posted by Xubuntu56
Why does this until false; do history | head -5; done
result in a stdout infinite loop, yet until false; do history | head -5 > hist5; done
only writes it once to file hist5? Furthermore, I can hear the hard drive working on the 2nd command until I end the process, but the history | head -5 is only written once.

It does not write once. It writes continously without break the same 5 lines into hist5 file over and over and generates considerable load at your machine. Since every session has its own history this makes no sense to do.


I'm unsure, but I assume .bash_history file is written at logout. If you want to see another sessions history with this, this will not work.
This User Gave Thanks to stomp For This Post:
Xubuntu56 (5 Days Ago)
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Redirecting stdout output to whiptail menu box annacreek Shell Programming and Scripting 0 08-11-2018 01:30 PM
Stdout in file Manu1234567 Shell Programming and Scripting 1 10-06-2013 04:11 AM
Redirecting STDERR to file and screen, STDOUT only to file thuranga Shell Programming and Scripting 18 09-10-2012 11:10 AM
File descriptors, redirecting output, and stdout Michael_K Shell Programming and Scripting 2 07-23-2012 02:16 PM
Preserve output order when redirecting stdout and stderr Boemm Shell Programming and Scripting 8 12-29-2009 11:22 AM
CPU usage: PS versus TOP - Different output liav Red Hat 4 10-27-2009 07:40 AM
Print C file output both in stdout and file nicos Programming 8 11-14-2008 12:35 PM
Redirecting part of output to stdout Legend986 Shell Programming and Scripting 2 10-17-2008 03:20 PM
Creating an Array in KSH from output (stdout) carlos25 Shell Programming and Scripting 2 09-25-2008 12:45 AM
let curl output to stdout AND save to a file scarfake Shell Programming and Scripting 3 05-31-2008 04:16 PM
getting stderr & stdout output lively modified teo ramirez Shell Programming and Scripting 2 10-08-2007 01:06 AM
Dual output (stdout and file) AdrianM Shell Programming and Scripting 2 03-23-2007 12:35 PM
Script Output Woes (stdout?) c0nn0r Shell Programming and Scripting 2 07-09-2006 05:22 PM
sending syslog output to stderr or stdout dmirza UNIX for Advanced & Expert Users 1 10-24-2005 06:41 PM
CTRL+H versus ^? versus BACKSPACE alan UNIX for Dummies Questions & Answers 3 07-23-2003 01:08 PM