Bash shell scripting question.
I am trying to write a script, the problem is, I need to 'cat /dev/urandom' into a file for a certain amount of time. Since /dev/urandom will never end, the command will never complete and my script will more-or-less halt.
I've been experimenting with background processes. My idea was to send 'cat /dev/urandom > ./blah' to the background, and in the foreground have the shell wait for a certain amount of time then kill the background process.
cat /dev/urandom > ./blah &
kill [backgroud process pid]
I, however, don't know how to tell the script the PID of the background process. I know typing 'jobs' in the shell will output the commands in the background, and I could possibly cut the output of that down with something like awk or sed to just what I need, but that seems overly complicated.
Can anyone enlighten me as to a simple way to do this?