User Tools

Site Tools


copy_move_delete

Copy Move Delete

2016



To Copy/Delete a file use cp

  To copy a file use:
  cp filename path/filename
  
  To copy the file test.txt to the folder /home/pi/new
  cp test.txt /home/pi/new


Copying Directories (and contained files)

  To copy a directory
  cp -avr source_directory destination_directory
  
  To copy the directory /home/pi/dir1 to the folder /home/pi/test
  cp -avr /home/pi/dir1 /home/pi/test
  
  Now you will have a /home/pi/test/dir directory


The attributes -avr represent

  a   Preserve the specified attributes such as directory and file mode, ownership, timestamps, etc.
  v   Show results
  r   Recursive, action all subfolders and files.



To Move use mv

  To Move a file
  mv source destination
  
  To move a file called test.txt from /home/pi to /home/pi/tmp
  mv /home/pi/test.txt /home/pi/tmp
  
  mv works with directorys too
  To move the folder /home/pi/Trial to the folder /mnt use
  mv /home/pi/Trial /mnt (you may need to sudo depending on destination directory rights)



To Delete use rm

  To Delete a file
  rm filename
  
  To delete a directory (even if it is empty)
  rm -R directory



copy_move_delete.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1