Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
41
rated 0 times [  41] [ 0]  / answers: 1 / hits: 350785  / 2 Years ago, fri, december 24, 2021, 4:51:11

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

More From » bash

 Answers
5

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"

[#30203] Saturday, December 25, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mouedi

Total Points: 420
Total Questions: 109
Total Answers: 116

Location: Philippines
Member since Wed, Aug 19, 2020
4 Years ago
;