How can I send some specific number of, say 1000, messages (echo) per second to a file by a shell script?
i.e. I want to echo 1000 such messages ("hi") per sec to a (tmp) file. echo "hi" >> tmp
How can I send some specific number of, say 1000, messages (echo) per second to a file by a shell script?
i.e. I want to echo 1000 such messages ("hi") per sec to a (tmp) file. echo "hi" >> tmp
Best you can do is this:
while :; do
i=0
while [ $i -lt 1000 ]; do
echo hi >> tmp
i=$((i+1))
done
sleep 1
done
The time to actually execute the commands in the inner while loop is not taken into account, so this will write slightly less messages per second.