unix - I need list of files in long format that contain string -


i want have list of files, in long format (ls -l) including date , time, contain specific string , if possible, number of occurrences.

the have achieved list of files (just name) number of occurrences:

grep -c 'string' * | grep -v :0 

that shows like: filename:number of occurrences

but cannot improve show file date , time. has simple, bit newbie.

i have used -s ignoring folder warnings. ':0$' regex ending in :0. awk calls ls -l on filenames found, | tr '\n' ' ' replaces newlines of ls command spaces. output number of occurences @ end of each line don't lose info while going forward. last awk print columns needed.

grep -c 'form-group' * -s | grep -v ':0$' | awk -f ':' '{ printf system( "ls -l \"" $2 "\" | tr \"\n\" \" \"" ); print " " $3 }' | awk -f ' ' '{ print $6 " " $7 " " $8 " " $9 " : " $11 }' 

here sample output:

sep 1 13:47 xxx.blade.php : 12 sep 1 13:47 xxx.blade.php : 5 sep 1 13:47 xxx.blade.php : 6 sep 11 17:25 xxx.blade.php : 4 sep 4 15:03 xxx.blade.php : 6 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -