Skip to content

Instantly share code, notes, and snippets.

@cGuille
Created November 25, 2016 14:59
Show Gist options
  • Select an option

  • Save cGuille/2192db5149c82067951af2550d02be1d to your computer and use it in GitHub Desktop.

Select an option

Save cGuille/2192db5149c82067951af2550d02be1d to your computer and use it in GitHub Desktop.
Really simple Bash script to prefix input lines with the current date
#!/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