I want to run this command:
ls -arth Test*log | tail -1
... and pass its output as an argument to:
open /Applications/Utilities/Console.app
I would like to do this all in one line.
Answer
This is known as command substitution:
open /Applications/Utilities/Console.app "$(ls -arth Test*log | tail -1)"
If you're certain that the output of the command you're substituting won't contain spaces or newlines (or if you want to supply space/newline-separated output as multiple arguments), you can omit the quotes:
open /Applications/Utilities/Console.app $(ls -arth Test*log | tail -1)
No comments:
Post a Comment