Link to home
Start Free TrialLog in
Avatar of M DXYZ
M DXYZFlag for United States of America

asked on

bash script to find file type

Hi, I need assistance creating a bash script which main purpose would be to search an specific mount directory /mnt/directories in which it will list the amount of files per directory and its file types as well a total global amount of files and total amount of file types. For example if there are 2 directories marc and john under /mnt/directories it will list their file type under each directory, file size per directory and then it will give the total amount of files for instance .doc or .xls 16 files .xls and 15 files .doc. Also it should provide the total amount of files added based on date per extension.
SOLUTION
Avatar of MikeOM_DBA
MikeOM_DBA
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of M DXYZ

ASKER

ok first of all I would appreciate if you could tell me a way to use the find command to find the file type, this would really help.

Regards,

michael
SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of M DXYZ

ASKER

My first step to this would be to list all of the files that will have the extensions found and then to find todays date.

I would appreciate your help.



#!/bin/bash
 
find /mnt -type f | xargs -n1 basename | awk -F"." '/\./ {print $NF}' | sort | uniq -c | sort -rn|cut -c 9-40>ext
 
while true
do
  cat ext| while read file
  do
    find / -name *.$file > ext1
  done
done

Open in new window