Linux-shell篇之时间输出

一、date命令使用
使用date单独获取系统当前的年份、月份、日、小时、分钟、秒
date +"%Y-%m-%d %H:%M:%S"

二、echo命令使用(默认换行)
1、echo是内部命令还是外部命令?
type echo
2、其作用?
display a line of text
3、如何显示“The year is 2013. Today is 26.”为两行?
echo -e “The year is `date +%Y` \nToday is `date +%d`”
-e开启转译

三、printf命令使用(默认不换行)
1、printf是内部命令还是外部命令?
type printf
2、其作用?
printf format and printf data.
3、如何显示“The year is 2013. Today is 26.”为两行?
printf “The year is `date +%Y` \nToday is `date +%d` \n”
printf 是格式化输出,直接使用反斜杠转译

四、cal命令使用
cal 2019
cal 10 2019

发布了30 篇原创文章 · 获赞 0 · 访问量 1007

猜你喜欢

转载自blog.csdn.net/yaoyujie157/article/details/102612542