Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My teacher gave me a homework on combining find and file

Use find and file to display all files in the /home subdirectory tree, as well as a guess at what sort of a file they are.

I tried using pipeline but it didn't work out as I thought. Any ideas on how to combine both commands? Thanks! =)

share|improve this question

closed as not a real question by Dennis, Keltari, Ƭᴇcʜιᴇ007, Nifle, BinaryMisfit Jan 27 '13 at 15:40

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Shouldn't you be doing this on your own? – Nicole Hamilton Jan 27 '13 at 0:54
Geeze....did you even look at the man pages for find and file command before asking all of us? We all don't in general mind helping over hard points but you'll have to show that you have done a little work too. Afterall if you do not know this stuff, how are you going to make the big bucks....:-) – mdpc Jan 27 '13 at 5:22
@mdpc: Which student reads manuals/books? – TFM Jan 27 '13 at 6:43
Most of them which do not drop out in the first year (except marketing students). – Hennes Jan 27 '13 at 11:28

Here's a hint. You use the file command as an argument of the find command. Below is the output of my find command's help. Take a look at the "actions" section to see how you can use the file command with the find command.

Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

default path is the current directory; default expression is -print
expression may consist of: operators, options, tests, and actions:

operators (decreasing precedence; -and is implicit where no others are given):
      ( EXPR )   ! EXPR   -not EXPR   EXPR1 -a EXPR2   EXPR1 -and EXPR2
      EXPR1 -o EXPR2   EXPR1 -or EXPR2   EXPR1 , EXPR2

positional options (always true): -daystart -follow -regextype

normal options (always true, specified before other expressions):
      -depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf
      --version -xdev -ignore_readdir_race -noignore_readdir_race

tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N
      -cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME
      -ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN
      -links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE
      -nouser -nogroup -path PATTERN -perm [+-]MODE -regex PATTERN
      -readable -writable -executable
      -wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N
      -used N -user NAME -xtype [bcdpfls]

actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print
      -fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit
      -exec COMMAND ; -exec COMMAND {} + -ok COMMAND ;
      -execdir COMMAND ; -execdir COMMAND {} + -okdir COMMAND ;

Report (and track progress on fixing) bugs via the findutils bug-reporting
page at or, if you have no web access, by sending
email to <>


share|improve this answer

You should do your homework but anyway is your problem...

find /home -type f -exec file {} \;

-type specifies the result (f for file) -exec executes a program {} Is the name of file

share|improve this answer
That is very inefficient as the for EACH file you generate a new process. Think man think...and use xargs! – mdpc Jan 27 '13 at 5:19
@mdpc Or GNU find with -exec file '{}' \+ – slhck Jan 27 '13 at 14:04

Better and more efficient solution:

 find /home -type f -print0 | xargs -0 file

The above implementation assumes a later version of find and a Linux implementation. -print0 allows for those cases where special reserved characters are contained in the know like SPACES!

share|improve this answer

Not the answer you're looking for? Browse other questions tagged .