Good day, I am pretty new to Unix and I need to do this simple task.

I have a few files, let's name them file01, file02, file03 etc. and I need to copy each of them to one computer from a list. The list of nodes is in a text file. I could do that in a bash script but I think there could be a simpler solution, maybe using xargs?

Here is what I need to do

scp file{01...XX} user@(server from servers.txt):~/

I hope my problem is clear and thanks for answers.

2 Answers 2


I suppose you need:

xargs -I{} scp file{01...XX} user@{}:~/ < servers.txt
  • I'll be able to test this later today, but doesn't it copy all the files to every server in servers.txt? What I need is to copy file01 to 1. server, file02 to 2. server and so on.
    – davidv
    Commented Feb 16, 2015 at 6:52
  • 1
    @user2715488 please would you update your question with this additional requirement Commented Feb 16, 2015 at 9:44
  • @user2715488 unless the files are quite literally called file01, file02, etc., how is the mapping done?
    – muru
    Commented Feb 16, 2015 at 15:01
for Host in `cat servers.txt` ; do scp file* $Host: ; done

You must log in to answer this question.

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