Compile a simple Linux Shell script

Source: Internet
Author: User

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 "#! .

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.