Bash – How to access the last return value in bash

bash

Simple scenario: I'm looking for a wsdl file lost in the middle of a project.

$ find -name '*.wsdl'
./some/very/very/long/way/to/some/lost/directory/filename.wsdl

Now that I know where it is, I want to do something with this file, say edit it. Instead of copy/pasting the path behind my command, is it possible to use the path returned by find earlier ? Just like it's possible to access the last argument you've typed with !$ or you last command with !!.
I've read that it was possible with $?, but it only returns me an error: 0: command not found

$ echo $?
0: command not found

Best Answer

Run the command in the command substitution:

output=$(find -name '*.wsdl')

The output is now stored in the output variable which you can use as many times as you like, with the following command:

echo "$output"