1

I want to copy some files (created by jenkins) from a specific folder on the server to another server. My Jenkins scripts creates backup folders something like backup-1, backup-2 and backup-3 this is for the sake of example

Now i want a script to copy the content of latest build backup-3 in our example.

I know ls -t1 backup* | head -n 1 but it output something like backup-3:

how can i remove the ":". notice that there are another folders and files besides backup* in the desired path.

1 Answer 1

1

You want the -d, --directory option.

list directories themselves, not their contents

So ls -t -1 --directory backup* | head -n 1

2
  • head: option requires an argument -- 'n' or you could use -1 without the n. Or could reverse the order with -r then use tail -1
    – Xen2050
    Feb 12, 2019 at 11:27
  • You are right. I dropped the 1. Fixed.
    – berkes
    Feb 12, 2019 at 12:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .