[英]grep with piped date in Linux
I wanted to filter my date command in Linux by not having the Days printed out. 我想在Linux中过滤我的日期命令,因为没有打印出Days。 So I tried to do something like this in the Linux terminal (for example):
所以我试着在Linux终端上做这样的事情(例如):
date | grep -v 'Tuesday'
But, it didn't work . 但是,它没有用。 It prints nothing.
它什么都不打印。 Is this normal or did I make a mistake or something?
这是正常的还是我犯了错误?
Date can print in almost any format you want. 日期可以以您想要的几乎任何格式打印。 To print the date and time without the day of the week:
要打印没有星期几的日期和时间:
$ date '+%D %r'
05/17/17 02:09:22 PM
+%D %r
describes the format. +%D %r
描述格式。 There are many possible formats. 有许多可能的格式。 See
man date
for details. 有关详情,请参阅
man date
。
date | grep -v 'Tuesday'
This does not remove the days. 这并没有消除日子。 It removes any line that contains the string
Tuesday
. 它删除包含字符串
Tuesday
任何行。 Examples: 例子:
$ date
Wed May 17 14:14:12 PDT 2017
$ date | grep -v 'Wed'
$ date | grep -v 'Thu'
Wed May 17 14:14:20 PDT 2017
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.