Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I used mv to move some files from /source_dir/ to /target_dir/, which looked like: mv /source_dir/*some_regex* /target_dir/.
One of the files which started to move, file1, is now in both target_dir and source_dir.
target_dir/file1 weighs considerably less than source_dir/file1.
My question is: Is source_dir/file1 broken? Is it unaffected (in which case I can delete target_dir/file1 and rerun the mv.
The source file is removed after copying is finished. Therefore, source file stays unaffected until the operation is completed.
If moving on the same filesystem, a different mechanism is used, where the data stays in place.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
Suppose I just don't have the whole file, I just download the first part and it contains all the file signature/magic bytes. Can I use file command in Linux to get its type? I think this command detect the file signature at the beginning, but I am not sure if they have more validation of the rest of the files.
file(1) will look by default at the first 1Mb of the file.
If you're using it as a library (libmagic) from your own program, you can change that with magic_setparam(MAGIC_PARAM_BYTES_MAX), see its manpage.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I have 6 very big directorys and once a day I would like to check size each of this directories for my monitoring. Now I'm using du -s command but it take many time and significantly slows my server. Is any different better way to do this?
Depending on circumstances you could put those directories on seperate partitions, the "used" size of which you can check very quickly with df.
This, of course, means that the directories are limited to the size of their respective partitions, which could be a pain. Hence the "depending on circumstances".
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
By safety I mean if the transfer gets interrupted, how does that impact the data in both source and dest? Is it also dependent on the specific types of filesystems?
When working across filesystems mv really has no choice but copying the file, in effect doing whatever cp does and then unlinking the original file.
A simple strace shows this:
rename("/tmp/file.rand", "./file.rand") = -1 EXDEV (Invalid cross-device link)
^^^^^^^^^^^^^^^^^^^
After this point mv reads 65536 bytes at a time from one fd and writes them to the other and does an unlinkat at the end.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am using Cent-OS and I am trying to copy a file. I su to root first, then I execute:
cp test.txt /usr/java/jdk1.7.0_45/jre/lib/management
But I get an input/output error. Why can't I copy this file as root? Is there something that can lock a folder in Linux so root can't change it?
root is a concept to get around the system's permissions.
IO error is a more physical problem that could be of a much more varied nature. Common examples included faulty media, unreadable CDs, lost connection, and so on.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
How to delete folders using single line command irrespective of whether the folder is empty or non-empty?.. Any idea?
The rm(1) command has the flag -r for that. You should not use the -f flag with this command, unless you know what you are doing, as placing a wrong * or space can have you deleting a lot more than you intended.