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

限于喜欢 提交于 2019-12-01 02:34:30

Yes.

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

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 -

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

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

Just to throw it in, in bash:

date +"%d %m %Y" -f <(echo yesterday)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!