Linux egrep and join

I want to join two stat fields (date modified and name) in one line

 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

      

I need a conclusion

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

      

I tried a lot of tr, paste, perl but none worked. Thanks to

+3


source to share


2 answers


On Linux:

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

      

creates for example

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

      

and

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

      



creates strings like:

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

      

on OS X:

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

      

prints

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

      

+1


source


Through paste

and column

,



$ paste -d" " - - < file | column -t
File:  "expresso"  Modifica  :  2014-07-21  19:03:53.797915876  +0200
File:  "file"      Modifica  :  2014-08-17  02:19:14.116184772  +0200

      

0


source







All Articles