JosiahMaybe
Platinum Coder
I tried this but "too many open directories" and it got stuck writing.
I think I may be stuck with just home directory saving but still want all timestamps. Major change from this is -L for no recursive directories. X E.
Bash:
#!/bin/bash
#12/29/2023, 5:59PM, started, X E. 9:04PM, like done but is slow. X E.
function startXE() {
if [ -f "$1propsXE.txt" ]; then
echo "$1propsXE.txt exists";
rm -i "$1propsXE.txt";
if [ -f "$1propsXE.txt" ]; then
return;
else
echo "File deleted";
fi
else
echo "$1propsXE.txt does not exist";
fi
recurseXE $1 "$1propsXE.txt";
echo "X E." >> "$1propsXE.txt";
echo "Done. X E.";
#X E.
}
#X E.
function recurseXE() {
if cantUseXE $1; then
return;
fi
writeXE $1 $2;
while IFS= read -r line; do
if [[ "$line" != ".." && "$line" != "." ]]; then
if [ -d "$1$line" ] && [ ! -L "$1$line" ]; then
if [[ "$1$line" == */ ]]; then
recurseXE "$1$line" $2;
else
recurseXE "$1$line/" $2;
fi
else
writeXE "$1$line" $2;
fi
fi
done <<< "$(ls -a $1 | grep -v /)"
#X E.
}
#X E.
function writeXE() {
if cantUseXE $1; then
return;
fi
# Write lines in order what, created at, last modified, last accessed, last changed, permissions, owner, group, inode.
echo $1 >> $2
file=($(stat -c "%w %y %x %z %a %U %G %i" $1))
echo "${file[0]} ${file[1]} ${file[2]}" >> $2
echo "${file[3]} ${file[4]} ${file[5]}" >> $2
echo "${file[6]} ${file[7]} ${file[8]}" >> $2
echo "${file[9]} ${file[10]} ${file[11]}" >> $2
echo "${file[12]}" >> $2
echo "${file[13]}" >> $2
echo "${file[14]}" >> $2
echo "${file[15]}" >> $2
echo "" >> $2
#X E.
}
#X E.
#12/30/2023, 11:07AM, start. 11:09AM, like done, X E. 11:11AM like done.
function cantUseXE() {
if [ -e "$1" ]; then
return 1;
else
return 0;
fi
#X E.
}
#X E.
if [ $# -gt 0 ]; then
if [ -d "$1" ]; then
if [[ "$1" == */ ]]; then
startXE "$1";
else
startXE "$1/";
fi
else
if [ -f "$1propsXE.txt" ]; then
echo "$1propsXE.txt exists";
rm -i "$1propsXE.txt";
if [ -f "$1propsXE.txt" ]; then
return;
else
echo "File deleted";
fi
else
echo "$1propsXE.txt does not exist";
fi
writeXE $1 "$1propsXE.txt";
echo "X E." >> "$1propsXE.txt";
echo "Done. X E.";
fi
else
if [[ "$(pwd)" == */ ]]; then
startXE "$(pwd)";
else
startXE "$(pwd)/";
fi
fi
#X E.