Saturday, July 26, 2014

Copying files in Linux/Unix

  1. Copy an existing file in your current directory to another file in the current directory and then list your directory to prove that it was done:
    
         cp  file1  file2 
         ls
         
  2. Copy a file from a different directory to your current directory and then list your directory to prove that it was done:
    
         cp /etc/ifconfig my.config 
         ls
         
  3. Use the copy command with the "inquire" option. What happens when you try to copy one file to an already existing file?
    
         cp -i file1  file2  
         
  4. Use the recursive option to copy an entire subdirectory to a new subdirectory and then list both directories to prove that it worked:
    
         cp -R subdir1 subdir4 
         ls subdir1 subdir4
         
  5. The copy command accepts "wildcard" characters. Try the command below. What did it do? List the subdir1 subdirectory to find out.
    
         cp samp* subdir1 
         ls subdir1
         
  6. If you are copying a file from another location to the current directory and want its name to remain the same, you can use the shorthand "." to indicate the current directory. Try this for example and note what happens:
    
         cp /etc/ifconfig  . 
         ls
         

References

Reactions:

0 comments:

Post a Comment