I run the following bash command to format a log with a file inode and hash:
time find BASE_DIR -maxdepth 1 -mindepth 1 -type d |
sort |
xargs -P100 -n1 -IFF bash -ce "find FF -type f" |
sort |
xargs -n1 -I {} bash -ce "
FILE=$1; INODE=`stat -c '%i' $FILE`;
HASH=`cat $FILE | md5sum | cut -d' ' -f1`;
printf 'Name: %s - Inode: 0x%X - MD5: %s\n' $FILE $INODE $HASH;" {}
But every time I run this I get something like this:
Name: FILE1 - Inode: 0xFFFFFFFFFFFFFFFF> - MD5: SOME_MD5
Name: FILE1 - Inode: 0xFFFFFFFFFFFFFFFF> - MD5: SOME_MD5
Name: FILE1 - Inode: 0xFFFFFFFFFFFFFFFF> - MD5: SOME_MD5
Name: FILE1 - Inode: 0xFFFFFFFFFFFFFFFF> - MD5: SOME_MD5
The same file every time. How do I correctly pass the args to bash?
EDIT
I was able to solve the problem by changing the second xargs to:
xargs -n1 bash -ce '
path="$0";
inode=`stat -c "%i" $path`;
hash=`cat $path | md5sum | cut -d" " -f1`;
printf "Name: %s - InodeContext<0x%X> - MD5: %s\n" $path $inode $hash;'