I need to find all the mime-type of all the files in the folder.I wrote a small snippet like this.
for i in $(find /home/someFolder -type f);do file -b $i --mime-type;done
This is returning the following output.
text/html
application/msword
application/msword
text/html
text/html
text/html
application/msword
application/vnd.ms-excel
But can i get the extracted information from these output like only html
or msword
or png
.
html
msword
msword
Are there any libraries which I can use to know the detailed information of the file which should include mime type,size,strings inside the file and any other behavioural information.Any suggestions will help.
Do this:
find . -type f -print0 | xargs -0L1 file -b --mime-type | cut -d/ -f2
Much faster and safer than your for
approach.
(Obviously, replace .
with the path you want to start your search from.)