In general UNIX philosophy, tools should accept input from STDIN allowing them to be built in a pipeline. However I ran into a problem today where the date coreutil doesn’t respect data from STDIN:
λ echo "03/15/2025" | date +%s ## this produces the current timestamp, not the ides of march
1754961284
λ echo "03/15/2025" | date -d - +%s ## this produces 1754892000 every time
1754892000
λ date -d "03/15/2025" +%s ## produces
1742018400This question on superuser and this question on AskUbuntu both point out that there are a couple of ways to deal with this.
This is a new one for me:
λ echo "03/15/2025" | { read d; date -d "$d" +%s; }
1742018400But you can also use:
λ echo "03/15/2025" | date -d $(cat -) +%sto inject STDIN into the pipeline.
Both approaches end up being good general tricks for when you wish to preserve the pipeline construct but have a utility that breaks from the pipe oriented nature of UNIX philosophy.