Georgi D. Georgiev
Georgi D. Georgiev

Reputation: 227

How to check file types of multiple files using "file"

I'm solving this wargame challenge:

http://overthewire.org/wargames/bandit/bandit5.html

where you have a directory with multiple files, one of which holds the password to the next level. To find the hidded password, you need to find the only file with text in it(the other ones have a file type "data").

I checked the contents of the files with the "file" command and I found the password but I began to wonder how can I do it with one command. I tried using find but I can't get it to work.

Question: How can I pipe the output of find into file?

Upvotes: 0

Views: 134

Answers (1)

fedorqui
fedorqui

Reputation: 289815

You can use file with multiple arguments:

file file1 file2

So you can create a find statement looking for your desired files and then use the expression:

file $(find ... your_condition ...)

But probably the best way is to use -exec to perform an action on the found results:

find ... -exec file {} +

this performs the find and executes the file command on the result list.

Upvotes: 1

Related Questions