List all files, showing file types terminal

command linefiles

I am doing a university assignment at the moment which specifies that I list the command to; List all files, showing file types.

I have searched high and low to try and find the correct command to achieve this, but have had no luck!

Would somebody be able to help me out by pointing me in the right direction or maybe telling me what command could do this?

Best Answer

"List all files, showing file types."

To see all files in the current directory and their file type, try:

file ./*

Example:

$ file ./*
./apt.conf.d:                 directory
./listchanges.conf:           ASCII text
./preferences.d:              directory
./sources.list:               ASCII text
./sources.list.d:             directory
./trusted.gpg:                GPG key public ring

The above shows a human-readable form of the file type. Alternatively, one can print the file's mime-type:

$ file --mime-type ./*
./apt.conf.d:                 inode/directory
./listchanges.conf:           text/plain
./preferences.d:              inode/directory
./sources.list:               text/plain
./sources.list.d:             inode/directory
./trusted.gpg:                application/x-gnupg-keyring

file does a cursory examination of the content of each file to determine its type. The default output, as shown in both examples above, includes the file name and the file type. For more information, see man file.

Related Question