1

I am using this command,

find -name (file name) -ls | awk '{print $11,"\t",$5,"\t",$7,"\t",$8,$10}' 

to gather information of tons of files. However, some files are giving us weird numbers where date should be, if files are modified in 2018. was wondering if you have any suggestion on this to convert those numbers to standard format, i.e, May 2016, May 2017, May 2018. Have no problem with output of files that were modified before 2017.

Is there any way to get an output with current year in that format, like May 2018?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Jason
  • 45

2 Answers2

2

Since you are using Linux, you can make use of the -printf argument to the find command:

find -name 'pattern' -printf '%p\t\t%Tb %TY\n'

Sample output:

$ find -name 'file*' -printf '%p\t\t%Tb %TY\n'
./file1     Sep 2018
./file6     Sep 2018
./file4     Sep 2018
./file2     Sep 2018
./file3     Sep 2018
./file5     Sep 2018
Wildcard
  • 36,499
-1

try this command.

find . -name (file name) | xargs ls -l --time-style="+%b %Y" | awk '{print $NF,$3,$5,$6,$7}' OFS="\t"

ls -l --time-style="+%b %Y" this is used to change the time style to MMM YYYY in ls output.

Kamaraj
  • 4,365