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?

4
  • 1
    please provide the sample contents of 2017 and 2018 and expected output
    – Kamaraj
    Sep 14, 2018 at 1:23
  • date might be useful, with -d, --date=STRING
    – Xen2050
    Sep 14, 2018 at 2:03
  • would like have something like this, file name, user name, size, date, something like Sep 2016
    – Jason
    Sep 14, 2018 at 8:17
  • 1
    This is almost like Why not parse ls? and the same rationale applies. Sep 14, 2018 at 9:53

2 Answers 2

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
-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.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .