How to access the last return value in bash?

There is no special bash variable for that.

$? contains the exit code of the last command (0 = success, >0 = error-code)

You can use the output of find with the -exec flag, like this:

 find -name  '*.wsdl' -exec emacs {} \;

The {} is replaced with the file name found by find. This would execute the command for every found file. If you want to execute a command with all found files as arguments use a + at teh end like this:

  find -name '*.wsdl' -exec emacs {} +

This would open one emacs instance with all found .wsdl files opened in it.

A more general solution is to store the output in a variable:

result=$(find -name '*.wsdl')
emacs $result

This works with all commands, not just find. Though you might also use xargs:

  find -name '*.wsdl' | xargs emacs {}

Here's a quick hack that should do what you want with minimal keystrokes, if you don't mind that the last command is executed twice.

Use backtick, ala:



$ find . -name HardToFind.txt
$ vim `!!`

*edit: I see the above linked "possibly duped" question also contains this answer. still relevant directly to this one, so leaving it, but sorry for the dupe.

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"