Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Run a command for a specified time and then abort if time exceeds

Looked all over and I can't find the answer...

Simple question: How can I cat a large file for, lets say, 45 seconds and output it to the screen or redirect to another file.


share|improve this question

marked as duplicate by Michael Mrozek Feb 8 '12 at 20:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 4 down vote accepted

You could try:

timeout 45 cat yourfile

See also http://stackoverflow.com/questions/5161193/bash-script-that-kills-a-child-process-after-a-given-timeout

share|improve this answer
timeout is cleaner and allows the duration option to be specified in seconds, minutes, hours, as well as the option to specify which signal to send. cleaner and more readable – bsd Feb 8 '12 at 20:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.