0

How do I use the result of a command from the terminal?

e.g. lets say I use locate to find the path of a file.

locate -br ^filename.c$

can I write something like:

vim (locate -br ^filename.c$)

to directly open the file with vim?

Mayank Patel
  • 3,868
  • 10
  • 36
  • 59
orestiss
  • 2,183
  • 2
  • 19
  • 23
  • possible duplicate of [Using the result of a command as an argument in bash?](http://stackoverflow.com/questions/58207/using-the-result-of-a-command-as-an-argument-in-bash) – DevSolar Sep 13 '14 at 11:18

1 Answers1

3

It's called command substitution:

vim $(locate -br ^filename.c$)

Older syntax, less recognizable and thus not encouraged:

vim `locate -br ^filename.c$`
DevSolar
  • 67,862
  • 21
  • 134
  • 209