通过管道将参数传递给日期命令

use*_*748 1 unix shell

通过date -d从文件中读取将日期和时间传递给命令

我试过:

#cat temp.txt
2013/10/31 10:57:02
#cat temp.txt | xargs date -d
date: the argument `10:57:02' lacks a leading `+';
when using an option to specify date(s), any non-option
argument must be a format string beginning with `+'
Run Code Online (Sandbox Code Playgroud)

dev*_*ull 5

你可以说:

cat temp.txt | xargs -i date -d {}
Run Code Online (Sandbox Code Playgroud)

或避免Useless Use of cat

date -d "$(<temp.txt)"
Run Code Online (Sandbox Code Playgroud)