LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-04-2015, 11:39 PM   #1
Jykke
Member
 
Registered: Sep 2005
Posts: 201

Rep: Reputation: 19
copy a file and check before deleting the original


I am using my linux machine as a digital video recorder. I record the films on the local drive, because of speed and after the recording I have a postprocessing script that copies the file to my NAS. Now until now I did not include any delete original parts in my script but since the system seems to be operating ok - I would like to it now.

Apparently there are no integrity checks in cp? Of course, normally the copy goes ok, but just in case, is there another command that would check the integrity of the file like copy and verify? Alternative I could use a kind of move and verify command if one exists?
 
Old 12-04-2015, 11:47 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
cp itself doesn't seem to have such an option, but you can easily run cp --backup followed by a cmp to compare the two files, then if everything is OK delete the backup.

For details how to handle --backup and how to run cmp, please check the man pages.
 
Old 12-07-2015, 07:16 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
rsync does that for you https://unix.stackexchange.com/quest...o-local-drives
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] how to check small chunks compared to original file silvyus_06 Linux - Newbie 7 02-21-2011 08:41 PM
How to write a shell script which will check a file name in a dir and copy it siris Programming 3 04-08-2010 07:54 PM
Can I upgrade to 10.0 without deleting the original 9.0 install? BigCliff1951 Mandriva 1 05-09-2004 01:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration