[英]Find and Echo only the date (with format) in String Output on Bash
I am trying to get the date "+%a %b %d %R:%S %Y"
in bash. 我试图以bash形式获取date "+%a %b %d %R:%S %Y"
。
here's the sample command and output 这是示例命令和输出
$ xscreensaver-command --time XScreenSaver 5.32: screen non-blanked since Thu Oct 29 12:15:05 2015 (hacks: #184, #60)
I am trying to get the the value Thu Oct 29 12:15:05 2015
on the string. 我正在尝试在字符串上获取值Thu Oct 29 12:15:05 2015
。
How can I achieve this? 我该如何实现?
Try to append with GNU grep: 尝试附加GNU grep:
2>&1 | grep -Po 'since \K.*(?= \()'
Output: 输出:
Thu Oct 29 12:15:05 2015
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.