Little help on a linux command - connection

Hi there,

is there a linux freak with us who can correct this command line:

cp (ls -rt1 /var/lib/nethserver/ibay/backup/ecodms/*.zip | tail -1) /var/lib/nethserver/ibay/backup/

Within a script, it works fine, but I can not execute it on the commend line. What is my error?

TIA
Thorsten

PS.: The command takes just the latest / newest file from the source folder and copies it to target.

What does it show as a error?

Hi

This gives the latest file…

ls -t | head -1

The problem is probably with the “expansion”…

More background:

http://mywiki.wooledge.org/ParsingLs

My 2 cents
Andy

-bash: syntax error near unexpected token `(’

Using xargs -i works:

ls -rt1 /source/*.zip | tail -1 | xargs -i cp {} /target/subfolder

2 Likes