tee_last_line
This commit is contained in:
Executable
+26
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env miaou-bash
|
||||||
|
|
||||||
|
function write_text {
|
||||||
|
for ((i = 0; i < 10000; i++)); do echo "this is plain text #$i"; done
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
echo A
|
||||||
|
echo B
|
||||||
|
}
|
||||||
|
|
||||||
|
rm -f _stdout
|
||||||
|
time write_text >_stdout
|
||||||
|
wc -l _stdout
|
||||||
|
|
||||||
|
echo -------
|
||||||
|
rm _stdout
|
||||||
|
time {
|
||||||
|
write_text | tee /tmp/out.$$
|
||||||
|
last_line=$(tail -n1 /tmp/out.$$)
|
||||||
|
rm -f /tmp/out.$$
|
||||||
|
} >_stdout
|
||||||
|
wc -l _stdout
|
||||||
|
|
||||||
|
echo -------
|
||||||
|
echo "last_line = $last_line"
|
||||||
Reference in New Issue
Block a user