Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

On Ubuntu, how do you get all timestamps with file backup?

I tried this but "too many open directories" and it got stuck writing.
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.
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.
 
Okay, I think I figured how. Make writeXE take only one argument, path found, and use pwd to make path to file each time and make writeXE not depend on cantReadXE. I have been getting wierd stuff for one argument to writeXE that takes 2 when exported, it was writing out files to like my desktop, many. I quickly closed terminal. First argument was path to file. Is like my whole system compromised? It seems not but things starting with D and F which I can just reget may be compromised. Important stuff is at m. X E.
 
Here is like my current code. It has all paths correct but it says no such file or directory upon using "stat". Is there anything wrong with this?
Bash:
#!/bin/bash
function writeXE() {
    if [ -e "$1" ]; then
        return;
    fi
    path="";
    if [[ "$(pwd)" == */ ]]; then
        path="$(pwd)propsXE.txt";
    else
        path="$(pwd)/propsXE.txt";
    fi
    # Write lines in order what, created at, last modified, last accessed, last changed, permissions, owner, group, inode.
    #echo $1 >> $path
    file=($(stat -c "%w %y %x %z %a %U %G %i" "$1"))
    return;
    echo "${file[0]} ${file[1]} ${file[2]}" >> $path
    echo "${file[3]} ${file[4]} ${file[5]}" >> $path
    echo "${file[6]} ${file[7]} ${file[8]}" >> $path
    echo "${file[9]} ${file[10]} ${file[11]}" >> $path
    echo "${file[12]}" >> $path
    echo "${file[13]}" >> $path
    echo "${file[14]}" >> $path
    echo "${file[15]}" >> $path
    echo "" >> $path
    #X E.
}
#X E.
#12/29/2023, 5:59PM, started, X E. 9:04PM, like done but is slow. X E.
function startXE() {
    path="";
    if [[ "$(pwd)" == */ ]]; then
        path="$(pwd)propsXE.txt";
    else
        path="$(pwd)/propsXE.txt";
    fi
    if [ -f "$path" ]; then
        echo "$path exists";
        rm -i "$path";
        if [ -f "$path" ]; then
            return;
        else
            echo "File deleted";
        fi
    else
        echo "$path does not exist";
    fi
    #tester="$1propsXE.txt";
    export -f writeXE;
    #find $1 -mindepth 1 -not -path '*/\.*' -exec bash -c ''writeXE' $0 '$tester'' {} \;
    #find $1 -mindepth 0 -exec bash -c "writeXE {} $tester" \;
    find $1 -mindepth 0 -exec bash -c "writeXE {}" \;
    #find $1 -mindepth 0 -exec bash -c 'writeXE "$0" "$1"' {} "$tester" \;
    echo "X E." >> "$1propsXE.txt";
    echo "Done. X E.";
    #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.
I realize that ending code may need to be updated. X E.
 
Now I am getting this error.
Code:
bash: -c: line 1: `writeXE /home/norvel/Desktop/TabletsMaybe/ub2XE/Nexus 7 (2013) Wi-Fi/Pictures/imported/2023-06-30T21:09:27.828Z.png'
It is from this code.
Bash:
#!/bin/bash
function writeXE() {
    if [ ! -e $1 ]; then
        return;
    fi
    path="";
    if [[ "$(pwd)" == */ ]]; then
        path="$(pwd)propsXE.txt";
    else
        path="$(pwd)/propsXE.txt";
    fi
    # Write lines in order what, created at, last modified, last accessed, last changed, permissions, owner, group, inode.
    echo $1 >> $path
    file=($(stat -c "%w %y %x %z %a %U %G %i" $1))
    echo "${file[0]} ${file[1]} ${file[2]}" >> $path
    echo "${file[3]} ${file[4]} ${file[5]}" >> $path
    echo "${file[6]} ${file[7]} ${file[8]}" >> $path
    echo "${file[9]} ${file[10]} ${file[11]}" >> $path
    echo "${file[12]}" >> $path
    echo "${file[13]}" >> $path
    echo "${file[14]}" >> $path
    echo "${file[15]}" >> $path
    echo "" >> $path
    #X E.
}
#X E.
#12/29/2023, 5:59PM, started, X E. 9:04PM, like done but is slow. X E.
function startXE() {
    path="";
    if [[ "$(pwd)" == */ ]]; then
        path="$(pwd)propsXE.txt";
    else
        path="$(pwd)/propsXE.txt";
    fi
    if [ -f "$path" ]; then
        echo "$path exists";
        rm -i "$path";
        if [ -f "$path" ]; then
            return;
        else
            echo "File deleted";
        fi
    else
        echo "$path does not exist";
    fi
    #tester="$1propsXE.txt";
    export -f writeXE;
    #find $1 -mindepth 1 -not -path '*/\.*' -exec bash -c ''writeXE' $0 '$tester'' {} \;
    #find $1 -mindepth 0 -exec bash -c "writeXE {} $tester" \;
    find $1 -mindepth 0 -exec bash -c 'writeXE '{}'' \;
    #find $1 -mindepth 0 -exec bash -c 'writeXE "$0" "$1"' {} "$tester" \;
    echo "X E." >> "$path";
    echo "Done. X E.";
    #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
    fi
else
    if [[ "$(pwd)" == */ ]]; then
        startXE "$(pwd)";
    else
        startXE "$(pwd)/";
    fi
fi
#X E.
X E.
 
Now I use this code which is mostly functional except it does not handle ( and space correct seemingly.
Bash:
find $1 -mindepth 0 -exec bash -c 'writeXE {}' \;
I am mostly sure it is wrong with this line. X E.
 
Here is exact errors with that.
Code:
bash: -c: line 1: `writeXE /home/norvel/Desktop/TabletsMaybe/ub2XE/Nexus 7 (2013) Wi-Fi/Pictures/imported/Gearsz.jpeg'
bash: -c: line 1: syntax error near unexpected token `('
bash: -c: line 1: `writeXE /home/norvel/Desktop/TabletsMaybe/ub2XE/Nexus 7 (2013) Wi-Fi/Pictures/Screenshots'
bash: -c: line 1: syntax error near unexpected token `('
bash: -c: line 1: `writeXE /home/norvel/Desktop/TabletsMaybe/ub2XE/Nexus 7 (2013) Wi-Fi/Pictures/Screenshots/screenshot20230702_185109780.png'
X E.
 
Like my screen froze and I forced power off upon running as sudo and waiting for about 50MB and opening a folder in /proc/. Last line was this.
Code:
/opt/lampp/share/man/man3/ldap_url_parse.3
2023-12-20 10:18:56.327868529 -0500
2023-12-20 10:18:56.327868529 -0500
2024-01-02 21:28:49.430165034 -0500
2023-12-20 10:18:56
This is like my current code.
Bash:
#!/bin/bash
function writeXE() {
    if [ ! -e "$1" ]; then
        return;
    fi
    path="";
    if [[ "$(pwd)" == */ ]]; then
        path="$(pwd)propsXE.txt";
    else
        path="$(pwd)/propsXE.txt";
    fi
    #echo $1;
    # Write lines in order what, created at, last modified, last accessed, last changed, permissions, owner, group, inode.
    echo $1 >> $path
    file=($(stat -c "%w %y %x %z %a %U %G %i" "$1"))
    echo "${file[0]} ${file[1]} ${file[2]}" >> $path
    echo "${file[3]} ${file[4]} ${file[5]}" >> $path
    echo "${file[6]} ${file[7]} ${file[8]}" >> $path
    echo "${file[9]} ${file[10]} ${file[11]}" >> $path
    echo "${file[12]}" >> $path
    echo "${file[13]}" >> $path
    echo "${file[14]}" >> $path
    echo "${file[15]}" >> $path
    echo "" >> $path
    #X E.
}
#X E.
#12/29/2023, 5:59PM, started, X E. 9:04PM, like done but is slow. X E.
function startXE() {
    path="";
    if [[ "$(pwd)" == */ ]]; then
        path="$(pwd)propsXE.txt";
    else
        path="$(pwd)/propsXE.txt";
    fi
    if [ -f "$path" ]; then
        echo "$path exists";
        rm -i "$path";
        if [ -f "$path" ]; then
            return;
        else
            echo "File deleted";
        fi
    else
        echo "$path does not exist";
    fi
    #tester="$1propsXE.txt";
    export -f writeXE;
    #find $1 -mindepth 1 -not -path '*/\.*' -exec bash -c ''writeXE' $0 '$tester'' {} \;
    #find $1 -mindepth 0 -exec bash -c "writeXE {} $tester" \;
    
    find $1 -mindepth 0 -exec bash -c 'writeXE "{}"' \;
    #find "$1" -mindepth 0 -print0 | xargs -0 -I {} bash -c 'writeXE "$@"' _ {}
    #find $1 -mindepth 0 -exec bash -c 'writeXE "$0" "$1"' {} "$tester" \;
    echo "X E." >> "$path";
    echo "Done. X E.";
    #X E.
}
#X E.
if [ $# -gt 0 ]; then
    if [ -d "$1" ]; then
        if [[ "$1" == */ ]]; then
            startXE "$1";
        else
            startXE "$1/";
        fi
    fi
else
    if [[ "$(pwd)" == */ ]]; then
        startXE "$(pwd)";
    else
        startXE "$(pwd)/";
    fi
fi
#X E.
Should I try again or is there some Linux thing I should know? X E.
 
I have been stopping it at 50MB and like my system should be like 31GB but some apps show 251GB. Like my question now is: should I just let it run? It is slow enough it does take about a day. I guess for now I can just record for important stuff like my Home directory but I still try for all recorded. Is there anything I should know and has anyone ever tried running "find" all way through like this? X E.
 
I tried this but "too many open directories" and it got stuck writing.
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.
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.
yea, as I mentioned before, unfortunately you're going to have to take that performance hit.
 
I tried all way through, it quit at about 71MB when it hit core18 and core20. That was not a performance issue, that was this system cannot handle that. Apparently this system cannot do this maybe. I was using a version which echo s all paths to console so I know progress. X E.
 
I just realized, like my code before "find" made it to /proc which is past that. Maybe this can be done. I filed a bug report with Ubuntu. Back to recursive function. I also notice that there was always a few directories that "find" cannot use that like my recursive function could. I am unsure what I can do about /proc though. Apparently /proc makes processes and files and folders based on processes including like my code. "find" seemed to be same speed as other code too. I had it doing with no variable to hold and just that command with ls in like my recursive code. For compatibility I think I should do recursive. X E.
 
I think that /proc can be conquered via a live USB. That way processes are on that live USB. That is also dangerous. Worth a shot though. Maybe I should make a backup image first though and like my Disks upon making partition image tries for entire 2TB so that is impractical, can you help with that? X E.
 
I think I fixed some stuff in like my recursive code. I made a local variable and now it is 2.5 seconds for each 1/10th MB, it was about 3 seconds for that.
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
    local manifest="$(ls -a $1 | grep -v /)"
    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 <<< "$manifest"
    #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
    fi
else
    if [[ "$(pwd)" == */ ]]; then
        startXE "$(pwd)";
    else
        startXE "$(pwd)/";
    fi
fi
#X E.
This is like a fastest version so far and that fix to a local variable may prevent hang at /proc. I may try this soon. Probably with a logger of what is currently so I know what is happening. X E.
 
I made it work. No errors or unaccessed directories. Here is code that did that.
Bash:
#!/bin/bash
#12/29/2023, 5:59PM, started, X E. 9:04PM, like done but is slow. X E.
function startXE() {
    echo "input writing directory: "
    read dir
    if [ -z "$dir" ]; then
        dir=""
    fi
    if [[ "$dir" != */ ]]; then
        dir="$dir/"
    fi
    if [ -f ""$dir"propsXE.txt" ]; then
        echo ""$dir"propsXE.txt exists"
        rm -i ""$dir"propsXE.txt"
        if [ -f ""$dir"propsXE.txt" ]; then
            return
        else
            echo "File deleted"
        fi
    else
        echo ""$dir"propsXE.txt does not exist"
    fi
    if [ -f ""$dir"propErXE.txt" ]; then
        echo ""$dir"propErXE.txt exists"
        rm -i ""$dir"propErXE.txt"
        if [ -f ""$dir"propErXE.txt" ]; then
            return
        else
            echo "File deleted"
        fi
    else
        echo ""$dir"propErXE.txt does not exist"
    fi
    recurseXE "$1" ""$dir"propsXE.txt" ""$dir"propErXE.txt"
    echo "X E." >> ""$dir"propsXE.txt"
    echo "Done. X E."
    #X E.
}
#X E.
function recurseXE() {
    if cantUseXE "$1"; then
        echo ""
        echo "cannot access $1"
        echo ""
        echo "cannot access $1" >> "$3"
        return
    fi
    writeXE "$1" "$2" "$3"
    local manifest="$(ls -a "$1" | grep -v /)"
    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" "$3"
                else
                    recurseXE "$1$line/" "$2" "$3"
                fi
            else
                writeXE "$1$line" "$2" "$3"
            fi
        fi
    done <<< "$manifest"
    #X E.
}
#X E.
function writeXE() {
    if cantUseXE "$1"; then
        echo ""
        echo "cannot access $1"
        echo ""
        echo "cannot access $1" >> "$3"
        return
    fi
    echo "$1"
    # 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 [ ! -f "$1" ]; then
        return 1;
    elif [ -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
    fi
else
    if [[ "$(pwd)" == */ ]]; then
        startXE "$(pwd)";
    else
        startXE "$(pwd)/";
    fi
fi
#X E.
Now I think I can just have like an incremental thing where I just record Home. It took hours and all through "Files" was not responding. Even after I had to close then reopen "Files". I can change how setter makes things like before so only set things remain. That was about 220MB for a 31GB system. I guess I am done. Be sure to monitor this if running as it could loop some possibly but should not. That one requires absolute path for paths if there is any way to fix that then maybe this can be improved. Otherwise it is as good as it gets. To answer like my original question, yes it can be done. This took some doing but it works now. X E.
 
I made it work. No errors or unaccessed directories. Here is code that did that.
Bash:
#!/bin/bash
#12/29/2023, 5:59PM, started, X E. 9:04PM, like done but is slow. X E.
function startXE() {
    echo "input writing directory: "
    read dir
    if [ -z "$dir" ]; then
        dir=""
    fi
    if [[ "$dir" != */ ]]; then
        dir="$dir/"
    fi
    if [ -f ""$dir"propsXE.txt" ]; then
        echo ""$dir"propsXE.txt exists"
        rm -i ""$dir"propsXE.txt"
        if [ -f ""$dir"propsXE.txt" ]; then
            return
        else
            echo "File deleted"
        fi
    else
        echo ""$dir"propsXE.txt does not exist"
    fi
    if [ -f ""$dir"propErXE.txt" ]; then
        echo ""$dir"propErXE.txt exists"
        rm -i ""$dir"propErXE.txt"
        if [ -f ""$dir"propErXE.txt" ]; then
            return
        else
            echo "File deleted"
        fi
    else
        echo ""$dir"propErXE.txt does not exist"
    fi
    recurseXE "$1" ""$dir"propsXE.txt" ""$dir"propErXE.txt"
    echo "X E." >> ""$dir"propsXE.txt"
    echo "Done. X E."
    #X E.
}
#X E.
function recurseXE() {
    if cantUseXE "$1"; then
        echo ""
        echo "cannot access $1"
        echo ""
        echo "cannot access $1" >> "$3"
        return
    fi
    writeXE "$1" "$2" "$3"
    local manifest="$(ls -a "$1" | grep -v /)"
    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" "$3"
                else
                    recurseXE "$1$line/" "$2" "$3"
                fi
            else
                writeXE "$1$line" "$2" "$3"
            fi
        fi
    done <<< "$manifest"
    #X E.
}
#X E.
function writeXE() {
    if cantUseXE "$1"; then
        echo ""
        echo "cannot access $1"
        echo ""
        echo "cannot access $1" >> "$3"
        return
    fi
    echo "$1"
    # 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 [ ! -f "$1" ]; then
        return 1;
    elif [ -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
    fi
else
    if [[ "$(pwd)" == */ ]]; then
        startXE "$(pwd)";
    else
        startXE "$(pwd)/";
    fi
fi
#X E.
Now I think I can just have like an incremental thing where I just record Home. It took hours and all through "Files" was not responding. Even after I had to close then reopen "Files". I can change how setter makes things like before so only set things remain. That was about 220MB for a 31GB system. I guess I am done. Be sure to monitor this if running as it could loop some possibly but should not. That one requires absolute path for paths if there is any way to fix that then maybe this can be improved. Otherwise it is as good as it gets. To answer like my original question, yes it can be done. This took some doing but it works now. X E.
Glad to hear that this is finally to the standards you wanted it. I will definitely keep tabs on this for any changes you may make and see how each change impacts performance
 
I just realized, to avoid permission issues I should set in most inner first order. Reverse order with like my program should work. This is a program that I think should load in reverse order and use minimal RAM.
Bash:
while IFS= read -r line; do
    # Process the line here
    cline=$(echo "$line" | rev)
    # Use in reverse order lines with same order of data in clines.
done < <(tac file.txt)
#X E
Am I wrong on anything? I may reverse like my put in order too. Anyway, I think this should work. X E.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom