Managing Files Using Command-Line Tools

 


ActivitySingle SourceMultiple Source
Copy Filecp File-1 File-2cp File-1 File-2 File-3 Directory
Move Filemv File-1 File-2mv File-1 File-2 File-3 Directory
Remove Filerm File-1rm -f File-1 File-2 File-3
Create Directorymkdir Directorymkdir -p Directory-1/Directory-2/Directory
Copy Directorycp -r Directory-1 Directory-2cp -r Directory-1 Directory-2 Directory-3 Dircetory
Move Directorymv Directory-1 Directory-2mv Directory-1 Directory-2 Directory-3 Dircetory
Remove Directoryrm -r Directroy-1rm -rf Directory- Directory-2 Directory
Remove Empty Directoryrmdir Directory-1rmdir -p Directory-1/Directory-2/Directory


Create Directories:-
--------------------
The mkdir command creates one or more directories or subdirectories, generating errors if the  file name already exists or when attempting to create a directory in a parent directory that doesn't
exist. The -p parent option creates missing parent directories for the requested destination. Be cautious when using mkdir -p, since accidental spelling mistakes create unintended directories
without generating error messages.

[root@localhost ~]# mkdir Desktop/Bharat/Abhishek
mkdir: cannot create directory ‘Desktop/Bharat/Abhishek’: No such file or directory

Note:- "The mkdir failed because the directory Bharat does not exist. If the user had used mkdir with the -p option, there would be no error and the user would end up with directories, Bharat, and the Watched subdirectory would be created in the wrong place." 

[root@localhost ~]# mkdir -p Desktop/Bharat/Abhishek

[root@localhost ~]# ll Desktop/Bharat/
total 0
drwxr-xr-x. 2 root root 6 Mar  2 03:37 Abhishek

[root@localhost ~]# mkdir -p Downloads/Abhishek/Pathak Downloads/Bharat/Delhi

[root@localhost ~]# ll Downloads/Abhishek/
total 0
drwxr-xr-x. 2 root root 6 Mar  2 03:43 Pathak

[root@localhost ~]# ll Downloads/Bharat/
total 0
drwxr-xr-x. 2 root root 6 Mar  2 03:43 Delhi


Create Blank File:-
-------------------
"touch" command is used to create a file without any content. The file created using the touch command is empty. This command can be used when the user doesn’t have data to store at the time of file creation.

[root@localhost ~]# touch Ayodhya_{1..5}.txt
[root@localhost ~]# ll
-rw-r--r--. 1 root root    0 Mar  2 03:55 Ayodhya_1.txt
-rw-r--r--. 1 root root    0 Mar  2 03:55 Ayodhya_2.txt
-rw-r--r--. 1 root root    0 Mar  2 03:55 Ayodhya_3.txt
-rw-r--r--. 1 root root    0 Mar  2 03:55 Ayodhya_4.txt
-rw-r--r--. 1 root root    0 Mar  2 03:55 Ayodhya_5.txt

You can define the specific locatin also to create blank file
[root@localhost ~]# touch Videos/Abhishek_{1..5}.Mp3
[root@localhost ~]# ll Videos/
total 0
-rw-r--r--. 1 root root 0 Mar  2 03:56 Abhishek_1.Mp3
-rw-r--r--. 1 root root 0 Mar  2 03:56 Abhishek_2.Mp3
-rw-r--r--. 1 root root 0 Mar  2 03:56 Abhishek_3.Mp3
-rw-r--r--. 1 root root 0 Mar  2 03:56 Abhishek_4.Mp3
-rw-r--r--. 1 root root 0 Mar  2 03:56 Abhishek_5.Mp3






No comments:

Post a Comment

Computer Hardware_(A+) & Operating System with Networking

Microprocessor Motherboard About Operating System Create Bootable Pen Drive via Command Map Network Drive File Transfer Protocol in Windows ...