Home > Mobile >  any way to use linux command file recursively?
any way to use linux command file recursively?

Time:02-03

I use this really useful command :

 file * 

to get quality/identity of listed files.

But I'd like to list recursively, from a given folder.
In another words, doing something like that :
(command below does not exist)

 file * -r

Any trick to do it ?

CodePudding user response:

You can use find for that, using the -exec switch:

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

CodePudding user response:

Another option is to use xargs(1):

find . | xargs file

Sample output:

./.config/xfe:                 directory
./.config/xfe/xfirc:           ASCII text
./.Xauthority:                 X11 Xauthority data
./line/serialLG1800.py:        Python script, ...

If file names contain spaces or other special characters, it is best to use the -print0 option for find and, doing so, also must add -0 option for xargs:

find . -print0 | xargs -0 file
  •  Tags:  
  • Related