Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 通过管道传递参数到日期命令_Shell_Unix - Fatal编程技术网

Shell 通过管道传递参数到日期命令

Shell 通过管道传递参数到日期命令,shell,unix,Shell,Unix,通过读取文件将日期和时间传递给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 `+

通过读取文件将日期和时间传递给
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 `+'
你可以说:

cat temp.txt | xargs -i date -d {}
或者避免,

date-d“$(你可以说:

cat temp.txt | xargs -i date -d {}
或者避免,

date-d“$(您也可以使用-0

$ cat temp.txt | xargs -0 date -d
当输入项可能包含空格、引号或 反斜杠

也可以使用-0

$ cat temp.txt | xargs -0 date -d
当输入项可能包含空格、引号或 反斜杠


如果使用时间戳,请使用此命令:
cat temp.txt|xargs-i date-d@{}
如果使用时间戳,请使用此命令:
cat temp.txt|xargs-i date-d@{}