Skip to content

Instantly share code, notes, and snippets.

@mjg123
Created May 9, 2014 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjg123/8ecb7be6414ddfa979c8 to your computer and use it in GitHub Desktop.
Save mjg123/8ecb7be6414ddfa979c8 to your computer and use it in GitHub Desktop.
tiny shell script for adding timestamps to lines piped in from stdin
while read f; do
date +"%H:%M:%S " | tr -d '\n';
echo $f;
done
@mjg123
Copy link
Author

mjg123 commented May 9, 2014

[~] cat | ./timestamper.sh
Hello
14:46:45 Hello
how are you
14:46:50 how are you

@mjg123
Copy link
Author

mjg123 commented May 9, 2014

or, as a one-liner:

some-fancy-command | while read f; do date +"%H:%M:%S " | tr -d '\n'; echo $f; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment