Use output from command line as a parameter for a command

3

1

Possible Duplicate:
How to replace a command with the result of another in linux?

I'm able to parse my command output so it only shows the file name that I'm interested.

My question is, I want to be able to take the output and use it as a parameter for svn diff.

svn diff /filename_from_output/

Glide

Posted 2012-04-17T18:57:01.663

Reputation: 203

Question was closed 2012-07-15T04:46:35.543

1set the filename from output to a variable and pass that variable in to your command. foo = some command; some_other_command $foo; – Scott C Wilson – 2012-04-17T19:09:05.730

Answers

7

Normally, the following should work:

svn diff "$(your-command)"

$() is simple bash command substitution. The output of the command enclosed in $() will be substituted in the outer command.

slhck

Posted 2012-04-17T18:57:01.663

Reputation: 182 472

0

I usually enclose the command in backquotes. This works in tcsh too... I am just used to doing it this way because I write a bit of Perl.

svn diff `whatname.sh`

Or if the output can contain spaces:

svn diff "`whatname.sh`"

paddy

Posted 2012-04-17T18:57:01.663

Reputation: 1 119