Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.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
如何在solaris shell中打印自unix纪元以来的秒数_Unix_Date_Solaris - Fatal编程技术网

如何在solaris shell中打印自unix纪元以来的秒数

如何在solaris shell中打印自unix纪元以来的秒数,unix,date,solaris,Unix,Date,Solaris,有没有一种方法可以使用unixdate来打印自epoch以来的秒数 如果有办法,我愿意使用其他标准shell命令 (我使用的是Solaris,因此没有日期“+“%s”) 谢谢好吧,因为这是一个编程网站,我只需要编译如下内容: #include <stdio.h> #include <time.h> int main (void) { printf ("%d\n",time(0)); return 0; } #包括 #包括 内部主(空){ printf(“

有没有一种方法可以使用unix
date
来打印自epoch以来的秒数

如果有办法,我愿意使用其他标准shell命令

(我使用的是Solaris,因此没有
日期“+“%s”


谢谢

好吧,因为这是一个编程网站,我只需要编译如下内容:

#include <stdio.h>
#include <time.h>
int main (void) {
    printf ("%d\n",time(0));
    return 0;
}
#包括
#包括
内部主(空){
printf(“%d\n”,时间(0));
返回0;
}
:-)

您可以尝试nawk(但尝试使用perl命令进行双重确认,看看它们是否给出相同的结果)

试试这个

/usr/bin/truss/usr/bin/date2>&1 | grep^time | awk'{print$3}'


perl(perl-e‘print localtime’)不是一个可接受的答案吗?我想不出如何使用date命令。@MJB而不是‘print localtime’,与“date+%s”类似的perl表达式是“perl-e‘print time’”,“可能应该被视为别名epoch=”的重复(但这个问题有许多重复项)。”perl-e“打印时间”
#include <stdio.h>
#include <time.h>
int main (void) {
    printf ("%d\n",time(0));
    return 0;
}
nawk "BEGIN{print srand}"