gpt4 book ai didi

bash - Linux egrep 并加入

转载 作者:行者123 更新时间:2023-11-29 09:28:05 24 4
gpt4 key购买 nike

我想在一行中加入两个统计字段(修改日期和名称)

 stat *|egrep  'File|Modifica'

File: "expresso"
Modifica : 2014-07-21 19:03:53.797915876 +0200
File: "file"
Modifica : 2014-08-17 02:19:14.116184772 +0200

我希望输出将是

 File: "expresso"  Modifica : 2014-07-21 19:03:53.797915876 +0200
File: "file" Modifica : 2014-08-17 02:19:14.116184772 +0200

我尝试了很多 tr、paste、perl,但都没有用。谢谢

最佳答案

在 Linux 上:

stat -c 'File: %n Modified: %y' t*

例如生产

File: t Modified: 2014-07-30 09:56:20.000000000 +0200
File: tdir Modified: 2014-08-14 23:40:21.000000000 +0200
File: test Modified: 2014-08-22 14:35:26.000000000 +0200
File: test.xml Modified: 2014-08-03 20:36:42.000000000 +0200

stat -c 'File: %n Modified: %y' t* | column -t

产生如下行:

File:  t         Modified:  2014-07-30  09:56:20.000000000  +0200
File: tdir Modified: 2014-08-14 23:40:21.000000000 +0200
File: test Modified: 2014-08-22 14:35:26.000000000 +0200
File: test.xml Modified: 2014-08-03 20:36:42.000000000 +0200

在 OS X 上,:

stat -f 'File: %N Modified: %t%Sm' t* |column -t

打印

File:  t         Modified:  Jul  30  09:56:20  2014
File: tdir Modified: Aug 14 23:40:21 2014
File: test Modified: Aug 22 14:35:26 2014
File: test.xml Modified: Aug 3 20:36:42 2014

关于bash - Linux egrep 并加入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25461364/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com