Skip to content

Copying a file multiple times on the same folder using bash command line in linux


After a while with no new entries I am using this blog again as a personal notebook of useful tricks or code snippets I need to use from time to time.


In this case, I need to test a new 4Tb hard disk drive that I have just received making use of the disk's warranty because the original one was damaged (it overheated when making a large backup, which is exactly the use you are supposed to be giving a 4Tb hard disk drive...).


I learned about the problems in the original disk the hard way: just in the middle of the backup, it got stuck. No way to remove data, no way to restore it to factory default settings... with all your personal information into it.


So this time I am testing the disk to the maximum capacity by copying a file on the same folder a number of times. This is how I am doing it.

First, I chose a large file (I am using a Linux Mint 1.8 Gb file disk image to do the trick).


Then, I renamed it as "file.iso".


Finally, I wrote the following command at the bash prompt:


printf '%s\n' {1..750} | xargs -I {} cp file.iso file-{}.iso

And this way you can just check if the drive is functional or if it dies in the middle of the process... without your personal data on it.


The copy is on right now so I will publish an edited version of this entry when it is done to tell how it went.


:-)


By the way, just in case you were asking... The script is not mine. I tweaked it from SuperUser's website, by reading and learning from the smart guys at this thread... I think it is wise and honest to give credit to the real experts.


http://superuser.com/questions/379636/how-can-i-make-5-copies-of-one-file-easily


I hope you find it useful. Thank you for passing by.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options

Submitted comments will be subject to moderation before being displayed.