Copy multiple files to a directory Shell Script Code

Copy multiple files to a directory Shell Script 

 

Problem Statement : Write a shell script code to copy multiple files from one directory to another directory.

Copy multiple files to a directory Program will ask  the user for the name of new directory . After user enter the name of directory ,it will be created and the files can be copied from present working directory to this new Directory.

Next user need to enter number of files to be copied and then these files will be copied to new directory.

Command used for creating new Directory :  mkdir nameofdirectory.

Command used for file Copy : cp filename todirectory.

Copy multiple files to a directory Shell Script Code

 

Sample Output 1

mint@mint ~ $. /script.sh
Enter new dir:
news
Enter number of files:
1
Enter file name:
lol.sh

Sample Output 2

mint@mint ~ $. /script.sh
Enter new dir:
newdir
Enter number of files:
1
Enter file name:
sample.sh

Sample Output 3

mint@mint ~ $. /script.sh
Enter new dir:
news
Enter number of files:
1
Enter file name:
lol.sh
anil@ubuntu:~$ ./bol.sh
Enter new dir:
newdir
Enter number of files:
2
Enter file name:
lol.sh
Enter file name:
bol.sh