Bash scripting/command to change stdin?
Forum: Programming and Scripting
Topic: Bash scripting/command to change stdin?
started by: chaostic
Posted by chaostic on Jan. 25 2008,07:43I currently have a tty input (or tail -f) that gives me:
blah blah blah *number* blah blah.
I can use sed to remove the blah blah's since they are always the same.
But what I want to do is take the input, now:
and turn it into
I can't do this with sed because sed always adds a newline to the end of any pattern space.
Also, I wouldn't need to use sed to remove the blah blahs, because I basicly want a constantly updated "~" per line of input, continuously adding to the same line.
Posted by chaostic on Jan. 25 2008,07:55Never mind, found how to do it. I already had it in place for a different use, but here:
cat /dev/ttyu1 | grep --line-buffered "blah" | while read starvingcount; do echo -ne "~"; done;
Posted by ^thehatsrule^ on Jan. 25 2008,16:07
Posted by chaostic on Jan. 26 2008,13:01
I could do that, but then how would I get output? The biggest thing is that sed always adds a newline to the end of anything it prints out, filling the terminal buffer alot sooner then I want.
But, like I said. I figured it out, and found out about the sed -u option, which makes use a line buffer instead of its normal block buffer.
Posted by WDef on Jan. 26 2008,15:10[Deleted]
Not sure about reading from a terminal, but the '-W interactive' option to mawk (on dsl) switches on line buffering from stdin and switches off buffering to sdout, so this(?) might work (dunno):
I had some Perl examples above, but they probably needed to sysread and syswrite to do this unbuffered.