-
-
Save d630/46c00265785864d91b7cabf30604d983 to your computer and use it in GitHub Desktop.
bash: read stdin from pipe into variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% printf '%d\n' {1..10000} | { time a=$(</dev/stdin) ; echo "$a"; } | wc -c | |
real 0m0.027s | |
user 0m0.004s | |
sys 0m0.004s | |
48894 | |
% printf '%d\n' {1..10000} | { time read -rd '' a; echo "$a"; } | wc -c | |
real 0m0.041s | |
user 0m0.004s | |
sys 0m0.016s | |
48894 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment