During distributed parallel computing, you often need to upload compiled files to the same directory of each computing node. when there are many computing nodes, this work is quite tedious. the following example shows the script for transferring files to each node.
1. Create a file. The file name is transfile. The content is as follows:
#! /Bin/bash
SCP $1 node1: $ home
SCP $1 node2: $ home
........
SCP $1 noden: $ home
The first line of the script, with "#!" At the beginning, it is a special reminder-It tells shell which program should be used to explain my script. In this example, I use bash shell/bin/bash. The first line must use "#!" Otherwise, the script will not run (the system considers it a text file ). Other lines starting with "#" are only used by the author and readers. The computer skips these lines. In the above script, the parameters $0, $1, $2... Is the parameter passed to the script. 2. Change the file attribute to "executable" for the file owner. $ chmod U + x transfile 3, run: $. /transfile CPI # copy the file CPI to the same directory of the node1-n (here the user's home directory. in addition, you can put together some commands to be used and input them to the file one by one. then use the source command to pass it to the shell to run: $ source filename. In this case, you do not need to add "#! .