Herzlich Willkommen

Live processing contents

Monday, May 16, 2011

Program BASH "COPY PASTE" file LINUX


#!/bin/bash

# loop tentang menimpa file "Copy Paste file"
while [ $# -ne 2 ]; do
        echo "copas.sh error :number of input is not valid. It supposed be two inputs, origin file and destination file address separated by space";
        exit 1;
done

while [ -d $1 ];  do
        echo "copas.sh error:directory is not permitted";
        exit 1;
done

while [ ! -f $1 ]; do
        echo "copas.sh error:no origin file address provided";
        exit 1;
--AGINTA--
done
while [ -f $2 ]; do
        echo "are you sure you want to override this file";
        read jawab;
        case $jawab in
                    "y" | "Y" )
                                cp $1 $2;
                                echo "copas.sh berhasil";
                                exit 0;;
                    "n" | "N" )
                                echo "copas.sh cancelled by user";
                                exit 1;;
                    * )
                                echo "copas.sh error:invalid answer";
                                exit 1;;
        esac

done
cp $1 $2;
echo "copas.sh berhasil";

No comments:

Post a Comment