簡體   English   中英

使用 shellscript 從另一個目錄復制文件

[英]Copying files from another directory with shellscript

我有一個問題,我有一個腳本,它需要一個文件並將其復制到幾台計算機上。 但我的問題是文件在/opt/scripts 中,但要復制的文件在/opt/file/copy 中。 我怎么能不從其目錄中移動文件。

#Here I put a list or array of my server endings
IPS=('15' )

#Name of the file to copy t
FILE="$1"
DIRECTORY1=/opt/bots

# if number of parameters less than or equal to 0
if [ $# -le 0 ]; then
    echo "The tar name must be entered."
    exit 1
fi

# I loop through the array or list with a for
for i in ${IPS[@]}
    do
        xxxxxxxx

done```

如果要將文件從 serverA(在 /sourcedirectory 中)復制到 serverB(在 /targetdirectory 中),可以使用scp ,假設ssh已設置。

在服務器 A 上,執行:

cd /sourcedirectory
scp file useronserverB@serverB:/targetdirectory/

然后serverA上的文件沒有移動,它被復制到serverB上的/target目錄中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM