2016-05-07 3 views
-1

私は現在のbashには、このCMDスクリプトを変換するために苦労しています:バッチファイル

@ECHO OFF 

SET /P USERBACKUPSOURCE= SOURCE: 
SET /P USERBACKUPDEST= DESTINATION: 

XCOPY /W %USERBACKUPSOURCE% %USERBACKUPDEST% 

私は本当にすべてのヘルプはあなたが使用することができます

+2

「bash」を意味しますか?私は "シェル"は一般的な用語で、OSにとらわれないと考えています(cmd.exeはシェルと見なすことができますが、多くの場合、Linuxに関連しています)。 – kebs

+3

**本当に** MS-DOSを使用していますか?または、Windowsのコマンドラインを参照していますか? –

+0

申し訳ありません、私はbashとcmdスクリプト@kebsを意味しています –

答えて

4

をいただければ幸いですので、Linuxについて多くを知りません次のようなもの:

#!/bin/bash 
#SET /p equivalent in linux is "read -p" 
read -p 'Please enter SOURCE dir (ex: /root/source/) : ' source 
read -p 'Please enter DESTINATION dir (ex: /root/destination/) : ' destination 

#xcopy /w : Displays the following message and waits for your response before starting to copy files: 
#Press any key to begin copying file(s) 

read -r -p "Copy $source to $destination? [y/N] " response 
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]] 
then 
     #cp -i, --interactive: prompt before overwrite 
     #cp -R, -r, --recursive: copy directories recursively 
     cp -i -r $source $destination 
else 
     echo "Aborted" 
fi