Created
November 25, 2016 14:59
-
-
Save cGuille/2192db5149c82067951af2550d02be1d to your computer and use it in GitHub Desktop.
Really simple Bash script to prefix input lines with the current date
This file contains hidden or 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
| #!/usr/bin/env bash | |
| # Prefix stdin lines with current date and time. | |
| # Sample usage: | |
| # tail -f some/file.log |predate | |
| # Any given arguments are provided to date(1): | |
| # tail -f some/file.log |predate -u -Ins | |
| while read line | |
| do | |
| echo -n $(date $*) | |
| echo -e "\t$line" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment