Can I script recreation of files such their inodes/mtimes increase in filename order? Across subdirectories?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Long story short, I have a buggy Makefile that is missing a few prerequisite definitions and consequently accidentally relies on the "order" of files on disk (checked out from an SVN repo) as given by their inode number.*



This order seems to have changed after an SVN server migration (and, fair enough, this order is not something someone would deliberately rely upon). But the result is that my builds are broken, because the target that used to be built first (and triggered build of the prerequisite) is now built after other targets (that are erroneously missing that prerequisite).



I can fix the Makefile, but as a workaround for rebuilding older versions of the software (that still contain the Makefile bug), I would like a command or small script to:



  • recreate files and directories in ascending filename order

  • recursively across subdirectories

  • so the end result is inodes increase as filenames increase

Is this even possible?



Bash ideal but Python acceptable.



* I don't actually know that Make is visiting files in inode number, but it's definitely not doing it in alphabetical filename order. It could be modification time, but if so then the question is the same. If the order is completely random then the question is moot anyway. (I appreciate that it's likely to be specified as being arbitrary, but run with it).







share|improve this question















  • 2




    Are you sure you need them in inode-increasing order, and not in the order they appear via readdir() which would be down to how they are stored in the directories. What file system is it?
    – Stéphane Chazelas
    May 2 at 12:43











  • @StéphaneChazelas: Not sure at all, but the directory layout hasn't changed. This is XFS.
    – Lightness Races in Orbit
    May 2 at 13:00










  • The recipe fulfillment order I'm seeing does match an ordering on inode (and not an ordering on (mtime,inode) pair or on filename). But that could be just a co-incidence, I don't know. The sample size is only six files so it's kind of hard to tell.
    – Lightness Races in Orbit
    May 2 at 13:03











  • Does it match what you see in the ls -f output?
    – Stéphane Chazelas
    May 2 at 13:08










  • @StéphaneChazelas: No, but I have to run ls -fR (the files are in multiple subdirs) and I believe that command's "grouping" of results into the subdirectories is masking the overall ordering.
    – Lightness Races in Orbit
    May 2 at 13:38














up vote
0
down vote

favorite












Long story short, I have a buggy Makefile that is missing a few prerequisite definitions and consequently accidentally relies on the "order" of files on disk (checked out from an SVN repo) as given by their inode number.*



This order seems to have changed after an SVN server migration (and, fair enough, this order is not something someone would deliberately rely upon). But the result is that my builds are broken, because the target that used to be built first (and triggered build of the prerequisite) is now built after other targets (that are erroneously missing that prerequisite).



I can fix the Makefile, but as a workaround for rebuilding older versions of the software (that still contain the Makefile bug), I would like a command or small script to:



  • recreate files and directories in ascending filename order

  • recursively across subdirectories

  • so the end result is inodes increase as filenames increase

Is this even possible?



Bash ideal but Python acceptable.



* I don't actually know that Make is visiting files in inode number, but it's definitely not doing it in alphabetical filename order. It could be modification time, but if so then the question is the same. If the order is completely random then the question is moot anyway. (I appreciate that it's likely to be specified as being arbitrary, but run with it).







share|improve this question















  • 2




    Are you sure you need them in inode-increasing order, and not in the order they appear via readdir() which would be down to how they are stored in the directories. What file system is it?
    – Stéphane Chazelas
    May 2 at 12:43











  • @StéphaneChazelas: Not sure at all, but the directory layout hasn't changed. This is XFS.
    – Lightness Races in Orbit
    May 2 at 13:00










  • The recipe fulfillment order I'm seeing does match an ordering on inode (and not an ordering on (mtime,inode) pair or on filename). But that could be just a co-incidence, I don't know. The sample size is only six files so it's kind of hard to tell.
    – Lightness Races in Orbit
    May 2 at 13:03











  • Does it match what you see in the ls -f output?
    – Stéphane Chazelas
    May 2 at 13:08










  • @StéphaneChazelas: No, but I have to run ls -fR (the files are in multiple subdirs) and I believe that command's "grouping" of results into the subdirectories is masking the overall ordering.
    – Lightness Races in Orbit
    May 2 at 13:38












up vote
0
down vote

favorite









up vote
0
down vote

favorite











Long story short, I have a buggy Makefile that is missing a few prerequisite definitions and consequently accidentally relies on the "order" of files on disk (checked out from an SVN repo) as given by their inode number.*



This order seems to have changed after an SVN server migration (and, fair enough, this order is not something someone would deliberately rely upon). But the result is that my builds are broken, because the target that used to be built first (and triggered build of the prerequisite) is now built after other targets (that are erroneously missing that prerequisite).



I can fix the Makefile, but as a workaround for rebuilding older versions of the software (that still contain the Makefile bug), I would like a command or small script to:



  • recreate files and directories in ascending filename order

  • recursively across subdirectories

  • so the end result is inodes increase as filenames increase

Is this even possible?



Bash ideal but Python acceptable.



* I don't actually know that Make is visiting files in inode number, but it's definitely not doing it in alphabetical filename order. It could be modification time, but if so then the question is the same. If the order is completely random then the question is moot anyway. (I appreciate that it's likely to be specified as being arbitrary, but run with it).







share|improve this question











Long story short, I have a buggy Makefile that is missing a few prerequisite definitions and consequently accidentally relies on the "order" of files on disk (checked out from an SVN repo) as given by their inode number.*



This order seems to have changed after an SVN server migration (and, fair enough, this order is not something someone would deliberately rely upon). But the result is that my builds are broken, because the target that used to be built first (and triggered build of the prerequisite) is now built after other targets (that are erroneously missing that prerequisite).



I can fix the Makefile, but as a workaround for rebuilding older versions of the software (that still contain the Makefile bug), I would like a command or small script to:



  • recreate files and directories in ascending filename order

  • recursively across subdirectories

  • so the end result is inodes increase as filenames increase

Is this even possible?



Bash ideal but Python acceptable.



* I don't actually know that Make is visiting files in inode number, but it's definitely not doing it in alphabetical filename order. It could be modification time, but if so then the question is the same. If the order is completely random then the question is moot anyway. (I appreciate that it's likely to be specified as being arbitrary, but run with it).









share|improve this question










share|improve this question




share|improve this question









asked May 2 at 12:37









Lightness Races in Orbit

276210




276210







  • 2




    Are you sure you need them in inode-increasing order, and not in the order they appear via readdir() which would be down to how they are stored in the directories. What file system is it?
    – Stéphane Chazelas
    May 2 at 12:43











  • @StéphaneChazelas: Not sure at all, but the directory layout hasn't changed. This is XFS.
    – Lightness Races in Orbit
    May 2 at 13:00










  • The recipe fulfillment order I'm seeing does match an ordering on inode (and not an ordering on (mtime,inode) pair or on filename). But that could be just a co-incidence, I don't know. The sample size is only six files so it's kind of hard to tell.
    – Lightness Races in Orbit
    May 2 at 13:03











  • Does it match what you see in the ls -f output?
    – Stéphane Chazelas
    May 2 at 13:08










  • @StéphaneChazelas: No, but I have to run ls -fR (the files are in multiple subdirs) and I believe that command's "grouping" of results into the subdirectories is masking the overall ordering.
    – Lightness Races in Orbit
    May 2 at 13:38












  • 2




    Are you sure you need them in inode-increasing order, and not in the order they appear via readdir() which would be down to how they are stored in the directories. What file system is it?
    – Stéphane Chazelas
    May 2 at 12:43











  • @StéphaneChazelas: Not sure at all, but the directory layout hasn't changed. This is XFS.
    – Lightness Races in Orbit
    May 2 at 13:00










  • The recipe fulfillment order I'm seeing does match an ordering on inode (and not an ordering on (mtime,inode) pair or on filename). But that could be just a co-incidence, I don't know. The sample size is only six files so it's kind of hard to tell.
    – Lightness Races in Orbit
    May 2 at 13:03











  • Does it match what you see in the ls -f output?
    – Stéphane Chazelas
    May 2 at 13:08










  • @StéphaneChazelas: No, but I have to run ls -fR (the files are in multiple subdirs) and I believe that command's "grouping" of results into the subdirectories is masking the overall ordering.
    – Lightness Races in Orbit
    May 2 at 13:38







2




2




Are you sure you need them in inode-increasing order, and not in the order they appear via readdir() which would be down to how they are stored in the directories. What file system is it?
– Stéphane Chazelas
May 2 at 12:43





Are you sure you need them in inode-increasing order, and not in the order they appear via readdir() which would be down to how they are stored in the directories. What file system is it?
– Stéphane Chazelas
May 2 at 12:43













@StéphaneChazelas: Not sure at all, but the directory layout hasn't changed. This is XFS.
– Lightness Races in Orbit
May 2 at 13:00




@StéphaneChazelas: Not sure at all, but the directory layout hasn't changed. This is XFS.
– Lightness Races in Orbit
May 2 at 13:00












The recipe fulfillment order I'm seeing does match an ordering on inode (and not an ordering on (mtime,inode) pair or on filename). But that could be just a co-incidence, I don't know. The sample size is only six files so it's kind of hard to tell.
– Lightness Races in Orbit
May 2 at 13:03





The recipe fulfillment order I'm seeing does match an ordering on inode (and not an ordering on (mtime,inode) pair or on filename). But that could be just a co-incidence, I don't know. The sample size is only six files so it's kind of hard to tell.
– Lightness Races in Orbit
May 2 at 13:03













Does it match what you see in the ls -f output?
– Stéphane Chazelas
May 2 at 13:08




Does it match what you see in the ls -f output?
– Stéphane Chazelas
May 2 at 13:08












@StéphaneChazelas: No, but I have to run ls -fR (the files are in multiple subdirs) and I believe that command's "grouping" of results into the subdirectories is masking the overall ordering.
– Lightness Races in Orbit
May 2 at 13:38




@StéphaneChazelas: No, but I have to run ls -fR (the files are in multiple subdirs) and I believe that command's "grouping" of results into the subdirectories is masking the overall ordering.
– Lightness Races in Orbit
May 2 at 13:38










1 Answer
1






active

oldest

votes

















up vote
0
down vote













Give this script a list of filenames in the order you want their mod times to be set. They'll be set in increasing order, 1 second apart.



#!/bin/sh
# touch++: run touch to set mod time of file arguments,
# starting at indicated time and increasing by 1 second
# for each argument
# mp, 5/2/2018
usage()
echo "Usage: $0 -d "date" FILE ..." >&2


while getopts "d:" opt
do
case "$opt" in
d)
date="$OPTARG"
;;
*)
usage
exit 1
;;
esac
done
shift $((OPTIND-1))

if [ -z "$date" ]
then
usage
exit 1
fi
secs=$(date -d "$date" "+%s")
if [ $? != 0 ]
then
usage
exit 2
fi
echo setting times starting at $secs $(date -d "@$secs")
for f
do
touch -m -t $(date -d "@$secs" "+%Y%m%d%H%M.%S") -- "$f"
secs=$((secs + 1))
done





share|improve this answer























    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f441315%2fcan-i-script-recreation-of-files-such-their-inodes-mtimes-increase-in-filename-o%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Give this script a list of filenames in the order you want their mod times to be set. They'll be set in increasing order, 1 second apart.



    #!/bin/sh
    # touch++: run touch to set mod time of file arguments,
    # starting at indicated time and increasing by 1 second
    # for each argument
    # mp, 5/2/2018
    usage()
    echo "Usage: $0 -d "date" FILE ..." >&2


    while getopts "d:" opt
    do
    case "$opt" in
    d)
    date="$OPTARG"
    ;;
    *)
    usage
    exit 1
    ;;
    esac
    done
    shift $((OPTIND-1))

    if [ -z "$date" ]
    then
    usage
    exit 1
    fi
    secs=$(date -d "$date" "+%s")
    if [ $? != 0 ]
    then
    usage
    exit 2
    fi
    echo setting times starting at $secs $(date -d "@$secs")
    for f
    do
    touch -m -t $(date -d "@$secs" "+%Y%m%d%H%M.%S") -- "$f"
    secs=$((secs + 1))
    done





    share|improve this answer



























      up vote
      0
      down vote













      Give this script a list of filenames in the order you want their mod times to be set. They'll be set in increasing order, 1 second apart.



      #!/bin/sh
      # touch++: run touch to set mod time of file arguments,
      # starting at indicated time and increasing by 1 second
      # for each argument
      # mp, 5/2/2018
      usage()
      echo "Usage: $0 -d "date" FILE ..." >&2


      while getopts "d:" opt
      do
      case "$opt" in
      d)
      date="$OPTARG"
      ;;
      *)
      usage
      exit 1
      ;;
      esac
      done
      shift $((OPTIND-1))

      if [ -z "$date" ]
      then
      usage
      exit 1
      fi
      secs=$(date -d "$date" "+%s")
      if [ $? != 0 ]
      then
      usage
      exit 2
      fi
      echo setting times starting at $secs $(date -d "@$secs")
      for f
      do
      touch -m -t $(date -d "@$secs" "+%Y%m%d%H%M.%S") -- "$f"
      secs=$((secs + 1))
      done





      share|improve this answer

























        up vote
        0
        down vote










        up vote
        0
        down vote









        Give this script a list of filenames in the order you want their mod times to be set. They'll be set in increasing order, 1 second apart.



        #!/bin/sh
        # touch++: run touch to set mod time of file arguments,
        # starting at indicated time and increasing by 1 second
        # for each argument
        # mp, 5/2/2018
        usage()
        echo "Usage: $0 -d "date" FILE ..." >&2


        while getopts "d:" opt
        do
        case "$opt" in
        d)
        date="$OPTARG"
        ;;
        *)
        usage
        exit 1
        ;;
        esac
        done
        shift $((OPTIND-1))

        if [ -z "$date" ]
        then
        usage
        exit 1
        fi
        secs=$(date -d "$date" "+%s")
        if [ $? != 0 ]
        then
        usage
        exit 2
        fi
        echo setting times starting at $secs $(date -d "@$secs")
        for f
        do
        touch -m -t $(date -d "@$secs" "+%Y%m%d%H%M.%S") -- "$f"
        secs=$((secs + 1))
        done





        share|improve this answer















        Give this script a list of filenames in the order you want their mod times to be set. They'll be set in increasing order, 1 second apart.



        #!/bin/sh
        # touch++: run touch to set mod time of file arguments,
        # starting at indicated time and increasing by 1 second
        # for each argument
        # mp, 5/2/2018
        usage()
        echo "Usage: $0 -d "date" FILE ..." >&2


        while getopts "d:" opt
        do
        case "$opt" in
        d)
        date="$OPTARG"
        ;;
        *)
        usage
        exit 1
        ;;
        esac
        done
        shift $((OPTIND-1))

        if [ -z "$date" ]
        then
        usage
        exit 1
        fi
        secs=$(date -d "$date" "+%s")
        if [ $? != 0 ]
        then
        usage
        exit 2
        fi
        echo setting times starting at $secs $(date -d "@$secs")
        for f
        do
        touch -m -t $(date -d "@$secs" "+%Y%m%d%H%M.%S") -- "$f"
        secs=$((secs + 1))
        done






        share|improve this answer















        share|improve this answer



        share|improve this answer








        edited May 3 at 15:18


























        answered May 2 at 15:50









        Mark Plotnick

        16.9k23861




        16.9k23861






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f441315%2fcan-i-script-recreation-of-files-such-their-inodes-mtimes-increase-in-filename-o%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?