Link to home
Avatar of gudii9
gudii9Flag for United States of America

asked on

copy failed

saiganesh@LAPTOP-EJBON1NM ~
$ mkdir gp

saiganesh@LAPTOP-EJBON1NM ~
$ cp * gp/
[b]cp: -r not specified; omitting directory 'gp'[/b]

saiganesh@LAPTOP-EJBON1NM ~
$ cd gp

saiganesh@LAPTOP-EJBON1NM ~/gp

Open in new window

why i am geting above error while copying all files to gp directory? please advise
i want to try rm and rmdir also
ASKER CERTIFIED SOLUTION
Avatar of kenfcamp
kenfcamp
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
To remove a empty directory use
rmdir [folder-name]

Open in new window


To remove a directory and its contents use
rm -R [folder-name]

Open in new window


To remove a file use
rm [file.name]

Open in new window

Avatar of gudii9

ASKER

sh-4.4$ pwd                                                                                                                                                                                                                    
/home/cg/root                                                                                                                                                                                                                  
sh-4.4$ cat file1.txt                                                                                                                                                                                                          
cat: file1.txt: No such file or directory                                                                                                                                                                                      
sh-4.4$ touch f1.txt                                                                                                                                                                                                          
sh-4.4$ ls -ltr                                                                                                                                                                                                                
total 4                                                                                                                                                                                                                        
-rw-r--r-- 1 25335 25335 978 Jan 29 18:52 README.txt                                                                                                                                                                          
-rw-r--r-- 1 25335 25335   0 Jan 29 18:53 f1.txt                                                                                                                                                                              
sh-4.4$ mkdir gp                                                                                                                                                                                                              
sh-4.4$ ls -ltr                                                                                                                                                                                                                
total 8                                                                                                                                                                                                                        
-rw-r--r-- 1 25335 25335  978 Jan 29 18:52 README.txt                                                                                                                                                                          
-rw-r--r-- 1 25335 25335    0 Jan 29 18:53 f1.txt                                                                                                                                                                              
drwxr-xr-x 2 25335 25335 4096 Jan 29 18:53 gp                                                                                                                                                                                  
sh-4.4$ mv gp /home/cg/root_destination                                                                                                                                                                                        
sh-4.4$ pwd                                                                                                                                                                                                                    
/home/cg/root                                                                                                                                                                                                                  
sh-4.4$ ls -ltr                                                                                                                                                                                                                
total 4                                                                                                                                                                                                                        
-rw-r--r-- 1 25335 25335 978 Jan 29 18:52 README.txt                                                                                                                                                                          
-rw-r--r-- 1 25335 25335   0 Jan 29 18:53 f1.txt                                                                                                                                                                              
sh-4.4$ cd /home/cg/root_destination                                                                                                                                                                                          
sh-4.4$ ls -ltr                                                                                                                                                                                                                
total 0                                                                                                                                                                                                                        
sh-4.4$ pwd                                                                                                                                                                                                                    
/home/cg/root_destination                                                                                                                                                                                                      
sh-4.4$ ls -ltr                                                                                                                                                                                                                
total 0                                                                                                                                                                                                                        

not sure why mv command did not work

please advise
Avatar of gudii9

ASKER

$ cd chap1

$ ls -F
ex1.c    ex2.c    ex3.c    example/   exercise/  

$ mv * chap2/
i am trying above from below but not successful yet
https://www.thegeekstuff.com/2010/12/mv-command-examples/
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of gudii9

ASKER

Your move command worked as expected. This was your command:

mv gp /home/cg/root_destination

Explanation:
- gp is a directory
- /home/cg is a directory

The mv command moves the gp directory to the /home/cg directory.

Because you are specifying a destination named root_destination the mv command is renaming your gp directory to root_destination

And because your gp directory was empty, the ls -ltr is showing 0 files - the next pwd command is also showing correct output.

not clear.
can you please advise with any simple example?