23. Real-Time Log Timestamping
Beginner Mode
Start your terminal to use beginner mode.
Scenario
You're troubleshooting a service that produces untagged log output when run manually, making it difficult to analyze timing and sequence of events.
Task
Create a command that reads from standard input line by line and appends the current timestamp to the end of each line as it's read. Test it interactively by piping output to verify it works, then save the solution to a shell script at /usr/local/bin/timestamp.sh and make it executable so it can be used in any pipeline.
Example
# Before (untagged log output)
Application started
Processing request #1234
Database connection established
Request completed
# After (timestamped in real-time)
Application started - 2025-11-06 15:30:45
Processing request #1234 - 2025-11-06 15:30:46
Database connection established - 2025-11-06 15:30:47
Request completed - 2025-11-06 15:30:48
Terminal requires a larger screen
Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.
Linux Terminal Environment
Write and execute your solution in the terminal below.
Essential
Linux 0/29
AWS 0/10
Kubernetes 0/15
CI/CD 0/5
Networking 0/9
Need more practice in this area? Explore more questions →
Adobe
Accenture
Coinbase
EPAM
Twitch
Amazon
Kayak
Autodesk
Lyft
Revolut
RedHat
Bloomberg
Datadog
Palantir
TCS
HashiCorp
Google
DeutscheBank
GitHub
Apple
Cloudflare
Stripe
Microsoft
NVIDIA
GoDaddy
X
SAP
Spotify
Airbnb
Meta
Reddit
Yelp
Okta
Dropbox
Slack
ActivisionBlizzard
Zscaler
Uber
IBM
DeliveryHero
Robinhood
GitLab
Shopify
Samsung
Elastic
Twilio
Netflix
CrowdStrike
Ubisoft
Anthropic
Capital One
Splunk
Intel
AMD
Databricks