Pipe string to GNU Date for conversion - how to make it read from stdin? Pipe string to GNU Date for conversion - how to make it read from stdin? linux linux

Pipe string to GNU Date for conversion - how to make it read from stdin?


date -f tells it to do the same thing as -d except for every line in a file... you can set the filename to - to make it read from standard input.

echo "yesterday" | date +"%d %m %Y" -f -


Yes.

 echo "yesterday" | xargs date +"%d %m %Y" -d


You can use `command` or $(command) substitution:

date +"%d %m %Y" -d $(echo "yesterday")