Can I script recreation of files such their inodes/mtimes increase in filename order? Across subdirectories?
Clash 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).
bash centos files scripting python
 |Â
show 1 more comment
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).
bash centos files scripting python
2
Are you sure you need them in inode-increasing order, and not in the order they appear viareaddir()
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 thels -f
output?
â Stéphane Chazelas
May 2 at 13:08
@StéphaneChazelas: No, but I have to runls -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
 |Â
show 1 more comment
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).
bash centos files scripting python
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).
bash centos files scripting python
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 viareaddir()
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 thels -f
output?
â Stéphane Chazelas
May 2 at 13:08
@StéphaneChazelas: No, but I have to runls -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
 |Â
show 1 more comment
2
Are you sure you need them in inode-increasing order, and not in the order they appear viareaddir()
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 thels -f
output?
â Stéphane Chazelas
May 2 at 13:08
@StéphaneChazelas: No, but I have to runls -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
 |Â
show 1 more comment
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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
edited May 3 at 15:18
answered May 2 at 15:50
Mark Plotnick
16.9k23861
16.9k23861
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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