Solved

Linux Shell Scripting: Mime type without filename

Posted on 2013-11-08
2
206 Views
Last Modified: 2013-11-08
for f in *
do 
  mime=`file -i $f`
  echo $mime
done

Open in new window

How can I get it to return something like:
text/plain; charset=us-ascii
insteead of:
file.txt: text/plain; charset=us-ascii
0
Comment
Question by:hankknight
  • 2
2 Comments
 
LVL 19

Accepted Solution

by:
simon3270 earned 500 total points
ID: 39633964
Add "-b" as a parameter
    file -b -i $f
0
 
LVL 19

Expert Comment

by:simon3270
ID: 39633978
I've just answered this in another of your questions - do you want to close this as a duplicate question?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question