2016-05-07 10 views
-1

Ich kämpfe im Moment cmd Skript in bash zu konvertieren:Batch-Datei zu Bash-Skript

@ECHO OFF 

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

XCOPY /W %USERBACKUPSOURCE% %USERBACKUPDEST% 

Ich weiß es wirklich nicht viel über Linux so würde jede Hilfe

+2

Meinst du 'bash'? Ich denke, "Shell" ist ein allgemeiner Begriff, OS-Agnostiker (cmd.exe kann als eine Shell betrachtet werden, obwohl es wahr ist, dass oft mehr Linux bezogen). – kebs

+3

Verwenden Sie ** wirklich ** MS-DOS? Oder beziehst du dich auf die Befehlszeile in Windows? –

+0

Sorry editiert es, ich meinte bash und cmd skripte @kebs –

Antwort

4

geschätzt werden können, verwenden Sie etwas wie:

#!/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 
Verwandte Themen