0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

6 Comments

You are welcome :) By the way, just wondering: is this game open? I went through the first steps and it looks promising, but I don't want to enter where I am not invited!
What do you mean by open? If you mean open to anybody, I think it is. I started from Bandit because my wargame skills are very basic but there are options for advanced players.
I mean: can I participate?
find ... -exec file {} \; is definitely much better/safer than file $(find ... ). Would be even better with a + instead of \;
@BroSlow indeed. With + it just executes the command once. Updating, thanks!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.