In Linux what happens if 1000 files in a directory are moved to another location while another 300 files were...

Removing whitespace between consecutive numbers

How to not let the Identify spell spoil everything?

What will happen if I transfer large sums of money into my bank account from a pre-paid debit card or gift card?

How much mayhem could I cause as a fish?

Could an Apollo mission be possible if Moon would be Earth like?

Hosting images in SFMC - is it a good idea?

Am I correct in stating that the study of topology is purely theoretical?

Do authors have to be politically correct in article-writing?

Why do neural networks need so many training examples to perform?

Saint abbreviation

Can 5 Aarakocra PCs summon an Air Elemental?

Which RAF squadrons and aircraft types took part in the bombing of Berlin on the 25th of August 1940?

Prioritising polygons in QGIS

Why did the villain in the first Men in Black movie care about Earth's Cockroaches?

Current across a wire with zero potential difference

Is there a lava-breathing lizard creature (that could be worshipped by a cult) in 5e?

Does diversity provide anything that meritocracy does not?

How do I prevent a homebrew Grappling Hook feature from trivializing Tomb of Annihilation?

What is the industry term for house wiring diagrams?

Why does 0.-5 evaluate to -5?

Does it take energy to move something in a circle?

Can we "borrow" our answers to populate our own websites?

Does the ditching switch allow an A320 to float indefinitely?

Updating Statistics: Estimated Number of Rows not equal to Actual for Index Scan. Why?



In Linux what happens if 1000 files in a directory are moved to another location while another 300 files were added to the source directory?


Any way to sync directory structure when the files are already on both sides?rsync: delete only extraneous files with a timestamp earlier than the newest in the source directoryLinux Shell script to copy files from one location to another locationhow to check for duplicates and rename file if there are any while copying them from another sourcemoving files from one location to another while they are being usedHow to delete duplicate files of two folders?What happens in linux when you copy a hardlink on top of another hardlink to the same file?What happens if I edit a folder while copying it?ZIP: What are the temporary binary files which names start with `zi`?What happens if you delete a file while it was moving from one filesystem(ext4) to another(NTFS)?













3















In Linux what happens if 1000 files in a directory are moved to another location and another 300 files were added to the source directory while original 1000 files were being moved. Will the destination end up being 1300 files? or will there be 300 files remaining in the source folder.










share|improve this question







New contributor




Shayan Ahmad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    3















    In Linux what happens if 1000 files in a directory are moved to another location and another 300 files were added to the source directory while original 1000 files were being moved. Will the destination end up being 1300 files? or will there be 300 files remaining in the source folder.










    share|improve this question







    New contributor




    Shayan Ahmad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      3












      3








      3








      In Linux what happens if 1000 files in a directory are moved to another location and another 300 files were added to the source directory while original 1000 files were being moved. Will the destination end up being 1300 files? or will there be 300 files remaining in the source folder.










      share|improve this question







      New contributor




      Shayan Ahmad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      In Linux what happens if 1000 files in a directory are moved to another location and another 300 files were added to the source directory while original 1000 files were being moved. Will the destination end up being 1300 files? or will there be 300 files remaining in the source folder.







      linux filesystems operating-systems






      share|improve this question







      New contributor




      Shayan Ahmad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Shayan Ahmad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Shayan Ahmad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 3 hours ago









      Shayan AhmadShayan Ahmad

      192




      192




      New contributor




      Shayan Ahmad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Shayan Ahmad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Shayan Ahmad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          2 Answers
          2






          active

          oldest

          votes


















          11














          This depends on which tools you use: Let's check a few cases:



          If you run something along the lines of mv /path/to/source/* /path/to/dest/ int a shell, you will end up with the original 1000 files being moved, the new 300 being untouched. This comes from the fact, that the shell will expand the * before starting the move operation, so when the move is in progress, the list is already fixed.



          If you use Nautilus (and other GUI friends), you will end up the same way: It will run the move operation based on which files were selected - this doesn't change when new files show up.



          If you use your own program using syscalls along the line of loop over glob and only one mv until glob stays empty, you will end up with all 1300 files in the new directory. This is because every new glob will pick up the new files, that have showed up in the meantime.






          share|improve this answer



















          • 3





            What happens if you opendir() the source, then loop over readdir() or getdents()?

            – grawity
            3 hours ago













          • If you loop only once, then it won't change.

            – Eugen Rieck
            2 hours ago











          • Is that true for all filesystems, and regardless of the amount of files? I assumed the kernel generally returns live results through readdir(), and doesn't pre-cache them or anything.

            – grawity
            1 hour ago











          • The result-set of an opendir() is stable according to POSIX. A quick test with PHP's opendir() confirms that (but I tested only ext4).

            – Eugen Rieck
            1 hour ago











          • Turns out the result set of opendir() must be cached, as there is a limit on the number of returned values. This can't be true on a dynamic directory handle.

            – Eugen Rieck
            1 hour ago



















          3














          When you tell the system to move all the files from a directory, it lists all the files and then starts moving them. If new files appear in the directory, they aren't added to the list of files to move, so they'll remain in the original location.



          You can, of course, program a way of moving files different to mv which will periodically check for new files in the source directory.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });






            Shayan Ahmad is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1409532%2fin-linux-what-happens-if-1000-files-in-a-directory-are-moved-to-another-location%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            11














            This depends on which tools you use: Let's check a few cases:



            If you run something along the lines of mv /path/to/source/* /path/to/dest/ int a shell, you will end up with the original 1000 files being moved, the new 300 being untouched. This comes from the fact, that the shell will expand the * before starting the move operation, so when the move is in progress, the list is already fixed.



            If you use Nautilus (and other GUI friends), you will end up the same way: It will run the move operation based on which files were selected - this doesn't change when new files show up.



            If you use your own program using syscalls along the line of loop over glob and only one mv until glob stays empty, you will end up with all 1300 files in the new directory. This is because every new glob will pick up the new files, that have showed up in the meantime.






            share|improve this answer



















            • 3





              What happens if you opendir() the source, then loop over readdir() or getdents()?

              – grawity
              3 hours ago













            • If you loop only once, then it won't change.

              – Eugen Rieck
              2 hours ago











            • Is that true for all filesystems, and regardless of the amount of files? I assumed the kernel generally returns live results through readdir(), and doesn't pre-cache them or anything.

              – grawity
              1 hour ago











            • The result-set of an opendir() is stable according to POSIX. A quick test with PHP's opendir() confirms that (but I tested only ext4).

              – Eugen Rieck
              1 hour ago











            • Turns out the result set of opendir() must be cached, as there is a limit on the number of returned values. This can't be true on a dynamic directory handle.

              – Eugen Rieck
              1 hour ago
















            11














            This depends on which tools you use: Let's check a few cases:



            If you run something along the lines of mv /path/to/source/* /path/to/dest/ int a shell, you will end up with the original 1000 files being moved, the new 300 being untouched. This comes from the fact, that the shell will expand the * before starting the move operation, so when the move is in progress, the list is already fixed.



            If you use Nautilus (and other GUI friends), you will end up the same way: It will run the move operation based on which files were selected - this doesn't change when new files show up.



            If you use your own program using syscalls along the line of loop over glob and only one mv until glob stays empty, you will end up with all 1300 files in the new directory. This is because every new glob will pick up the new files, that have showed up in the meantime.






            share|improve this answer



















            • 3





              What happens if you opendir() the source, then loop over readdir() or getdents()?

              – grawity
              3 hours ago













            • If you loop only once, then it won't change.

              – Eugen Rieck
              2 hours ago











            • Is that true for all filesystems, and regardless of the amount of files? I assumed the kernel generally returns live results through readdir(), and doesn't pre-cache them or anything.

              – grawity
              1 hour ago











            • The result-set of an opendir() is stable according to POSIX. A quick test with PHP's opendir() confirms that (but I tested only ext4).

              – Eugen Rieck
              1 hour ago











            • Turns out the result set of opendir() must be cached, as there is a limit on the number of returned values. This can't be true on a dynamic directory handle.

              – Eugen Rieck
              1 hour ago














            11












            11








            11







            This depends on which tools you use: Let's check a few cases:



            If you run something along the lines of mv /path/to/source/* /path/to/dest/ int a shell, you will end up with the original 1000 files being moved, the new 300 being untouched. This comes from the fact, that the shell will expand the * before starting the move operation, so when the move is in progress, the list is already fixed.



            If you use Nautilus (and other GUI friends), you will end up the same way: It will run the move operation based on which files were selected - this doesn't change when new files show up.



            If you use your own program using syscalls along the line of loop over glob and only one mv until glob stays empty, you will end up with all 1300 files in the new directory. This is because every new glob will pick up the new files, that have showed up in the meantime.






            share|improve this answer













            This depends on which tools you use: Let's check a few cases:



            If you run something along the lines of mv /path/to/source/* /path/to/dest/ int a shell, you will end up with the original 1000 files being moved, the new 300 being untouched. This comes from the fact, that the shell will expand the * before starting the move operation, so when the move is in progress, the list is already fixed.



            If you use Nautilus (and other GUI friends), you will end up the same way: It will run the move operation based on which files were selected - this doesn't change when new files show up.



            If you use your own program using syscalls along the line of loop over glob and only one mv until glob stays empty, you will end up with all 1300 files in the new directory. This is because every new glob will pick up the new files, that have showed up in the meantime.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 3 hours ago









            Eugen RieckEugen Rieck

            10.4k22229




            10.4k22229








            • 3





              What happens if you opendir() the source, then loop over readdir() or getdents()?

              – grawity
              3 hours ago













            • If you loop only once, then it won't change.

              – Eugen Rieck
              2 hours ago











            • Is that true for all filesystems, and regardless of the amount of files? I assumed the kernel generally returns live results through readdir(), and doesn't pre-cache them or anything.

              – grawity
              1 hour ago











            • The result-set of an opendir() is stable according to POSIX. A quick test with PHP's opendir() confirms that (but I tested only ext4).

              – Eugen Rieck
              1 hour ago











            • Turns out the result set of opendir() must be cached, as there is a limit on the number of returned values. This can't be true on a dynamic directory handle.

              – Eugen Rieck
              1 hour ago














            • 3





              What happens if you opendir() the source, then loop over readdir() or getdents()?

              – grawity
              3 hours ago













            • If you loop only once, then it won't change.

              – Eugen Rieck
              2 hours ago











            • Is that true for all filesystems, and regardless of the amount of files? I assumed the kernel generally returns live results through readdir(), and doesn't pre-cache them or anything.

              – grawity
              1 hour ago











            • The result-set of an opendir() is stable according to POSIX. A quick test with PHP's opendir() confirms that (but I tested only ext4).

              – Eugen Rieck
              1 hour ago











            • Turns out the result set of opendir() must be cached, as there is a limit on the number of returned values. This can't be true on a dynamic directory handle.

              – Eugen Rieck
              1 hour ago








            3




            3





            What happens if you opendir() the source, then loop over readdir() or getdents()?

            – grawity
            3 hours ago







            What happens if you opendir() the source, then loop over readdir() or getdents()?

            – grawity
            3 hours ago















            If you loop only once, then it won't change.

            – Eugen Rieck
            2 hours ago





            If you loop only once, then it won't change.

            – Eugen Rieck
            2 hours ago













            Is that true for all filesystems, and regardless of the amount of files? I assumed the kernel generally returns live results through readdir(), and doesn't pre-cache them or anything.

            – grawity
            1 hour ago





            Is that true for all filesystems, and regardless of the amount of files? I assumed the kernel generally returns live results through readdir(), and doesn't pre-cache them or anything.

            – grawity
            1 hour ago













            The result-set of an opendir() is stable according to POSIX. A quick test with PHP's opendir() confirms that (but I tested only ext4).

            – Eugen Rieck
            1 hour ago





            The result-set of an opendir() is stable according to POSIX. A quick test with PHP's opendir() confirms that (but I tested only ext4).

            – Eugen Rieck
            1 hour ago













            Turns out the result set of opendir() must be cached, as there is a limit on the number of returned values. This can't be true on a dynamic directory handle.

            – Eugen Rieck
            1 hour ago





            Turns out the result set of opendir() must be cached, as there is a limit on the number of returned values. This can't be true on a dynamic directory handle.

            – Eugen Rieck
            1 hour ago













            3














            When you tell the system to move all the files from a directory, it lists all the files and then starts moving them. If new files appear in the directory, they aren't added to the list of files to move, so they'll remain in the original location.



            You can, of course, program a way of moving files different to mv which will periodically check for new files in the source directory.






            share|improve this answer




























              3














              When you tell the system to move all the files from a directory, it lists all the files and then starts moving them. If new files appear in the directory, they aren't added to the list of files to move, so they'll remain in the original location.



              You can, of course, program a way of moving files different to mv which will periodically check for new files in the source directory.






              share|improve this answer


























                3












                3








                3







                When you tell the system to move all the files from a directory, it lists all the files and then starts moving them. If new files appear in the directory, they aren't added to the list of files to move, so they'll remain in the original location.



                You can, of course, program a way of moving files different to mv which will periodically check for new files in the source directory.






                share|improve this answer













                When you tell the system to move all the files from a directory, it lists all the files and then starts moving them. If new files appear in the directory, they aren't added to the list of files to move, so they'll remain in the original location.



                You can, of course, program a way of moving files different to mv which will periodically check for new files in the source directory.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 3 hours ago









                chorobachoroba

                13.3k13341




                13.3k13341






















                    Shayan Ahmad is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    Shayan Ahmad is a new contributor. Be nice, and check out our Code of Conduct.













                    Shayan Ahmad is a new contributor. Be nice, and check out our Code of Conduct.












                    Shayan Ahmad is a new contributor. Be nice, and check out our Code of Conduct.
















                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1409532%2fin-linux-what-happens-if-1000-files-in-a-directory-are-moved-to-another-location%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Why do type traits not work with types in namespace scope?What are POD types in C++?Why can templates only be...

                    Will tsunami waves travel forever if there was no land?Why do tsunami waves begin with the water flowing away...

                    Simple Scan not detecting my scanner (Brother DCP-7055W)Brother MFC-L2700DW printer can print, can't...