I tried using a command like
cp `ls ~/temp/*.xyz | head -1` ./
But that does not work. If I echo the value of command inside back ticks and put it manually in cp command it works. Any ideas?
|
I tried using a command like
But that does not work. If I echo the value of command inside back ticks and put it manually in cp command it works. Any ideas? |
||||
|
|
|
The text produced by the backticks (or the alternate syntax There's a second issue: parsing the output of If you use zsh as your shell, an easy way to do what you're attempting is
On other shells, this is harder. On the command line, you might risk using
On other shells, you can do it this way (note that this overwrites the positional parameters):
|
|||
|
|
|
Maybe the matched file contains special characters (e.g. spaces) so you need to quote the back ticks expression: cp "`ls ~/temp/*.xyz | head -1`" . |
|||
|
|