WEBVTT - This file was automatically generated by VIMEO

0
00:00:13.300 --> 00:00:16.300
Hey and welcome back to

1
00:00:16.300 --> 00:00:16.900
 this video.

2
00:00:17.800 --> 00:00:20.100
So let's continue. So we have

3
00:00:20.100 --> 00:00:23.500
 seen how to copy a file from one source to another

4
00:00:23.500 --> 00:00:26.500
 destination. Let's quickly see some more

5
00:00:26.500 --> 00:00:29.800
 ways to copy files and directories. Alright,

6
00:00:29.800 --> 00:00:32.500
 so let's quickly create two directories called

7
00:00:32.500 --> 00:00:35.300
 as one and two so we have to

8
00:00:35.300 --> 00:00:38.500
 directories now. So let's quickly create two files

9
00:00:38.500 --> 00:00:41.900
 as well. So for that we are going to use the command which

10
00:00:41.900 --> 00:00:42.200
 is

11
00:00:43.300 --> 00:00:44.000
Nano

12
00:00:46.200 --> 00:00:50.000
let's call it as file 1 and hit

13
00:00:49.300 --> 00:00:52.800
 enter and let's say this is file one.

14
00:00:54.100 --> 00:00:58.200
And let's quickly save it come out of it Nano File

15
00:00:57.200 --> 00:00:58.600
 2.

16
00:01:00.700 --> 00:01:03.800
This is file to save it.

17
00:01:07.200 --> 00:01:10.700
And we have to folders or directories one

18
00:01:10.700 --> 00:01:13.200
 and two and two files which is file one

19
00:01:13.200 --> 00:01:16.500
 and file to perfect. So now

20
00:01:16.500 --> 00:01:19.600
 if I want to copy this file, which is a file

21
00:01:19.600 --> 00:01:22.900
 one. So I'm going to type the command CP file one

22
00:01:22.900 --> 00:01:25.800
 and copy it to the directory,

23
00:01:25.800 --> 00:01:26.500
 which is one.

24
00:01:27.800 --> 00:01:30.800
And this should have copied the file

25
00:01:30.800 --> 00:01:33.300
 into the directory, which is 1 you can

26
00:01:33.300 --> 00:01:36.400
 also verify using the command tree so tree one

27
00:01:36.400 --> 00:01:39.600
 and it entered and you can see the tree

28
00:01:39.600 --> 00:01:40.100
 structure.

29
00:01:40.800 --> 00:01:43.600
Of the directory, which is 1 and

30
00:01:43.600 --> 00:01:46.900
 there is a file which is a file one inside this

31
00:01:46.900 --> 00:01:48.200
 directory. Perfect.

32
00:01:49.900 --> 00:01:52.800
And you can see the output over here as well 0 directories

33
00:01:52.800 --> 00:01:55.900
 and one file inside one folder.

34
00:01:55.900 --> 00:01:58.900
 Okay. So now let's

35
00:01:58.900 --> 00:02:01.900
 say I want to copy this directory. So

36
00:02:01.900 --> 00:02:04.300
 let's say copy the directory two.

37
00:02:04.300 --> 00:02:07.200
 So before copying the directory, let's copy the

38
00:02:07.200 --> 00:02:10.700
 file to as well into the directory, which

39
00:02:10.700 --> 00:02:13.300
 is two and hit enter and let's type

40
00:02:13.300 --> 00:02:16.200
 the command tree two and see if there

41
00:02:16.200 --> 00:02:19.300
 is a file and yes, there is a file. So let me type

42
00:02:19.300 --> 00:02:22.300
 the command tree over here and you can see there is

43
00:02:22.300 --> 00:02:25.300
 a directory one, which has a file one. There is

44
00:02:25.300 --> 00:02:28.500
 a directory two, which has a file too and here we

45
00:02:28.500 --> 00:02:31.400
 have to files as well, which is file one and file

46
00:02:31.400 --> 00:02:34.000
 too. Great. Let me clear the screen for you.

47
00:02:34.600 --> 00:02:34.900
now

48
00:02:36.300 --> 00:02:39.800
Let's say I want to copy the directory which is 2 inside

49
00:02:39.800 --> 00:02:42.200
 the directory 1. So this time I do not

50
00:02:42.200 --> 00:02:45.200
 want to copy a file instead. I want to

51
00:02:45.200 --> 00:02:48.900
 copy a directory for that. I'm going to use the command CP. So

52
00:02:48.900 --> 00:02:51.400
 let's say copy to to copy one and

53
00:02:51.400 --> 00:02:54.500
 hit enter and here you can see we got

54
00:02:54.500 --> 00:02:57.600
 an error. It says you're trying to copy

55
00:02:57.600 --> 00:03:00.900
 a directory and not specified hyphen

56
00:03:00.900 --> 00:03:04.100
 R. So omitting the directory now

57
00:03:03.100 --> 00:03:06.900
 here if you want to copy a

58
00:03:06.900 --> 00:03:09.900
 directory, you have to specify hyphen R

59
00:03:09.900 --> 00:03:12.200
 then and only then you will be

60
00:03:12.200 --> 00:03:15.200
 able to copy those directories. And now when

61
00:03:15.200 --> 00:03:19.400
 I hit enter let's go inside one

62
00:03:18.400 --> 00:03:21.100
 and see or else we can

63
00:03:21.100 --> 00:03:22.700
 also use the command tree.

64
00:03:23.800 --> 00:03:26.700
And you can see inside the directory 1 we

65
00:03:26.700 --> 00:03:29.700
 have a directory which is 2 which contains a

66
00:03:29.700 --> 00:03:32.300
 file to and yes, we already copied a

67
00:03:32.300 --> 00:03:35.600
 file one inside the directory one, which is already present.

68
00:03:36.400 --> 00:03:39.100
Let's go inside one and see as

69
00:03:39.100 --> 00:03:42.800
 well the same structure. There is a file one and

70
00:03:42.800 --> 00:03:45.100
 there is a new directory which has

71
00:03:45.100 --> 00:03:48.000
 been copied over here, which is two if we go

72
00:03:48.100 --> 00:03:51.600
 inside two and hit enter and see here

73
00:03:51.600 --> 00:03:54.400
 we can find the file which is file to which

74
00:03:54.400 --> 00:03:57.000
 is exactly the same structure that we see over here.

75
00:03:57.800 --> 00:04:00.400
So I hope you guys understood how you

76
00:04:00.400 --> 00:04:03.500
 can copy directories recursively inside

77
00:04:03.500 --> 00:04:06.600
 another directories from one source to another

78
00:04:06.600 --> 00:04:09.800
 destination. This is very very handy, and people

79
00:04:09.800 --> 00:04:12.700
 many time make this mistakes while

80
00:04:12.700 --> 00:04:15.500
 copying directories, which you should always keep in

81
00:04:15.500 --> 00:04:17.900
 mind. I hope you guys understood. Thank you.
