Help! I somehow deleted Windows files that I need

Technical issues/questions of an intermediate or advanced nature.
User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Help! I somehow deleted Windows files that I need

Post#61 by Rava » 10 Oct 2023, 20:24

What version is testdisk-7.2-WIP-x86_64-rava.xzm

Is that the old one from 2020?


Because this one testdisk-7.2-WIP-x86_64-Aug2023.xzm should be the most recent one.

Also, when you code it like so

Code: Select all

TESTDISK="testdisk-7.2-WIP-x86_64-Aug2023.xzm" # version
TESTDISK="testdisk-7.2-WIP-x86_64-rava.xzm"
the "testdisk-7.2-WIP-x86_64-Aug2023.xzm" version can never be accessed because the next line overwrites the previous one. Is that on purpose?

Shall I create a testdisk-7.2-WIP-x86_64-Aug2023 version module and upload it?
(Sadly, due to lack of funds filehorst.de is no longer accepting new uploads, the old ones are still hosted, but new ones are rejected.)
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Help! I somehow deleted Windows files that I need

Post#62 by Ed_P » 10 Oct 2023, 20:28

Rava wrote:
10 Oct 2023, 20:24
What version is testdisk-7.2-WIP-x86_64-rava.xzm

Is that the old one from 2020?
Yes

Code: Select all

guest@porteus:/mnt/sda6/porteus5.0/Optional$ ls -on test*
-rwxrwxrwx 1 1000  516096 Nov 25  2020 testdisk-7.1-x86_64-1_SBo.xzm*
-rwxrwxrwx 1 1000 3235840 Sep 19 19:49 testdisk-7.1-x86_64-don.xzm*
-rwxrwxrwx 1 1000 5976064 Dec  9  2020 testdisk-7.2-WIP-x86_64-rava.xzm*
-rwxrwxrwx 1 1000 6008832 Sep 29 01:35 testdisk-7.2-WIP.--x86_64-Aug2023.xzm*
guest@porteus:/mnt/sda6/porteus5.0/Optional$ 
Added in 2 minutes 9 seconds:
Rava wrote:
10 Oct 2023, 20:24
the "testdisk-7.2-WIP-x86_64-Aug2023.xzm" version can never be accessed because the next line overwrites the previous one. Is that on purpose?
Yes. Same script, different module used. Easy to revert.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Help! I somehow deleted Windows files that I need

Post#63 by Rava » 10 Oct 2023, 20:32

I spotted this:
testdisk-7.2-WIP-x86_64-Aug2023.xzm
and
testdisk-7.2-WIP.--x86_64-Aug2023.xzm
the filenames do not match.
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Help! I somehow deleted Windows files that I need

Post#64 by Ed_P » 10 Oct 2023, 22:15

Rava wrote:
10 Oct 2023, 20:32
the filenames do not match.
That is an amazing observation. :shock:
Image
And renaming the file solves the script problem, :Yahoo!: Thank you :worthy: RAVA. :worship: :beer:
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Help! I somehow deleted Windows files that I need

Post#65 by Rava » 10 Oct 2023, 23:36

Ed_P wrote:
10 Oct 2023, 22:15
And renaming the file solves the script problem, :Yahoo!: Thank you :worthy: RAVA. :worship: :beer:
Therefore my above suggestion was
Rava wrote:
10 Oct 2023, 05:01
Leave out the > /dev/null 2>&1 part and see if it hides some crucial information.
to which you replied
Ed_P wrote:
10 Oct 2023, 05:41
Actually I did but the results weren't helpful so I didn't post the results.
How did you manage to overlook the "file not found" error message? O___o;
Did you really remove ALL > /dev/null 2>&1 parts?
Ed_P wrote:
10 Oct 2023, 16:17
And I have other scripts that activate Optional modules that's why this problem is so strange.
In the end the solution was not a bizarre behaviour by the shell, but a rather quite simple but overlooked coding error.
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Help! I somehow deleted Windows files that I need

Post#66 by Ed_P » 11 Oct 2023, 00:16

Rava wrote:
10 Oct 2023, 23:36
How did you manage to overlook the "file not found" error message? O___o;
Did you really remove ALL > /dev/null 2>&1 parts?
I took it as part of the error window's msg. It didn't click. And if you check the script I posted above you will see my /dev/null code.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Help! I somehow deleted Windows files that I need

Post#67 by Rava » 11 Oct 2023, 00:55

Ed_P wrote:
11 Oct 2023, 00:16
I took it as part of the error window's msg. It didn't click. And if you check the script I posted above you will see my /dev/null code.
Hopefully you learn from that experience.

For the future:
Remove all and any /dev/null code

It might be even better if you create a copy of your script and use that copy to remove all /dev/null code and even add some "markers" like so:
#!/bin/bash
code
more code
echo DEBUG - 1
even more code
echo DEBUG - 2
even more code 2
even more code 3
echo DEBUG - 3
even more code 4
# etcetera pp
Highlighting to show you what I meant with 'add some "markers"' - if you just number the markers like in my example or give them unique descriptive names is up to you, usually I go by the more simple

Code: Select all

echo DEBUG1
[…]
echo DEBUG2
way of doing things. Also possible when you have a variable that gets changed is doing this:

Code: Select all

echo DEBUG1:
echo 'variable1$ - ' "variable1$"
echo 'variable2$ - ' "variable2$"
[…]
echo DEBUG2:
echo 'variable1$ - ' "variable1$"
echo 'variable2$ - ' "variable2$"
Just make sure when you do work on a copy of the script that you are always aware if you currently work on the copy or on the original of the script. Confusing both can make debugging even more confusing.

Work for the time being only on the copy with all >/dev/null removed - and when you get that script to work without any issues, either manually insert all >/dev/null into the copy, or insert the lesson or lessons learned from the copied-and-now-bugfree-script into your original.


Use whatever of these two technique floats your personal boat better, just not during debugging confuse one version with the other, like editing and saving one version but testing / running the other (=unedited one when it comes to the very last edit / debugging attempt) and being confused why your "changes" did make no difference. Believe me, happened to me in the past more than once. And that created unnecessary headaches and confusion.
A good example of why slow and thorough will get you quicker (and better) results than quick and dirty and confusing. :) :magic:
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Help! I somehow deleted Windows files that I need

Post#68 by Ed_P » 11 Oct 2023, 03:09

^ A simple link to your Ravas coding goodies post might be sufficient.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Help! I somehow deleted Windows files that I need

Post#69 by Rava » 11 Oct 2023, 17:53

Ed_P wrote:
11 Oct 2023, 03:09
^ A simple link to your Ravas coding goodies post might be sufficient.
In theory, but I posted the above first, and then posted a slightly enhanced version on Ravas coding goodies (to make it more generic to apply)

Added in 1 minute 15 seconds:
Anyhow, how is the restoring of files going?
Did you finally start the process?

An if "yes" is your answer, I presume it will take many hours?
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Help! I somehow deleted Windows files that I need

Post#70 by Ed_P » 11 Oct 2023, 19:19

Rava wrote:
11 Oct 2023, 17:54
but I posted the above first,
That shouldn't matter.

Added in 6 minutes 33 seconds:
Rava wrote:
11 Oct 2023, 17:54
Did you finally start the process?

An if "yes" is your answer, I presume it will take many hours?
I have, and it did, and I had to redo it several times before I set the Power Management's Suspend when Inactive setting to Never. I'm still trying to decide how to process all the files; weird named, original folder, completeness.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Help! I somehow deleted Windows files that I need

Post#71 by Rava » 11 Oct 2023, 19:29

Ed_P wrote:
11 Oct 2023, 19:26
I'm still trying to decide how to process all the files; weird named, original folder, completeness.
It is a chore. But at least you have the files back.
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Help! I somehow deleted Windows files that I need

Post#72 by Ed_P » 15 Oct 2023, 23:19

I know it's obvious to some but what am I missing??

Code: Select all

guest@porteus:/mnt/sda6$ grep -i "-2023 " testdisk.log
grep: invalid option -- ' '
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
guest@porteus:/mnt/sda6$ grep -i -2023  testdisk.log


^C
guest@porteus:/mnt/sda6$ cat testdisk.log | grep -i -2023 >> testdisk2023.txt
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
guest@porteus:/mnt/sda6$ cat testdisk.log | grep -i '-2023 ' >> testdisk2023.txt
grep: invalid option -- ' '
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
guest@porteus:/mnt/sda6$ cat testdisk.log | grep -i "-2023 " >> testdisk2023.txt
grep: invalid option -- ' '
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
guest@porteus:/mnt/sda6$ cat testdisk.log | grep -F "-2023 " >> testdisk2023.txt
grep: invalid option -- ' '
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
guest@porteus:/mnt/sda6$ cat testdisk.log | grep -F '-2023 ' >> testdisk2023.txt
grep: invalid option -- ' '
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
guest@porteus:/mnt/sda6$ 
 
I know the "-2023" exists in the file.

Code: Select all

   73575 -r--r--r--     0     0     10759 16-Sep-2023 00:23 My Utilities/FirefoxPortable/Data/profile/cache2/entries/5A84833AC677669F92C22170A71045DD3B224619
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Help! I somehow deleted Windows files that I need

Post#73 by Rava » 16 Oct 2023, 05:11

Ed_P wrote:
15 Oct 2023, 23:19
I know it's obvious to some but what am I missing??

Code: Select all

guest@porteus:/mnt/sda6$ grep -i "-2023 " testdisk.log
grep: invalid option -- ' '
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
guest@porteus:/mnt/sda6$ grep -i -2023  testdisk.log


^C
[…]
I know the "-2023" exists in the file.

Code: Select all

   73575 -r--r--r--     0     0     10759 16-Sep-2023 00:23 My Utilities/FirefoxPortable/Data/profile/cache2/entries/5A84833AC677669F92C22170A71045DD3B224619
The obvious is you not thinking of using "--"

When something starting with a "-" is getting you trouble, use it as the last given parameter together with a prior "--" - that tells all programs it's the end of all options.

Created a test file "dummy", here its contents, and one grep run with -- and one without:

Code: Select all

guest@rava:/tmp$ cat dummy 
blabla
Kafkaesque
-2023 blubbs
Whatever
Kafkaesque-2023 bla
blablubb
guest@rava:/tmp$ grep -i -- "-2023 " dummy 
-2023 blubbs
Kafkaesque-2023 bla
guest@rava:/tmp$ grep -i "-2023 " dummy 
/bin/grep: invalid option -- ' '
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
guest@rava:/tmp$ 
Does that help to get your train back on the correct track?

Added in 14 minutes 15 seconds:
Also, you not need the "-i" parameter here. Unless you are able to show me upper case numbers and lower case numbers. And no, "2" vs "²" and "3" vs "³" do not count.
Is a mere "2" upper case or lower case? And if is is one, what is the other case?

Answer: Arabic numerals do not have upper or lower cases.

Roman numerals on the other hand can have these:
IV vs iv and XXI vs xxi and such, though usually Roman numerals are written as upper case only.
Last edited by Rava on 16 Oct 2023, 05:30, edited 2 times in total.
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8374
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Help! I somehow deleted Windows files that I need

Post#74 by Ed_P » 16 Oct 2023, 06:34

Rava wrote:
16 Oct 2023, 05:25
The obvious is you not thinking of using "--"
:ROFL: You are right. I've never heard of "--", I have never used "--", and grep --help doesn't mention it. I would have thought any pattern between the quotes would have been taken literally.

Yes the addition of -- works. Thank you :worship: Rava. :friends:

Now that this step is resolved do you have any suggestions for my wanting to use multiple selections when reading the log file? I want the -2023 lines plus .sh lines and .jpg lines. I know I can create a file and then search through it and create another file and then repeat the process until I get what I want.

Thanks again for your help. <3

Added in 12 minutes 9 seconds:
This approach certainly didn't work.

Code: Select all

guest@porteus:/mnt/sda6$ grep  -- '-2023 ' testdisk.log | grep -i ".sh " 
   40209 -r--r--r--     0     0       809 10-Apr-2023 14:54 My Utilities/PSPad editor/PSPad editor/Syntax/CSH Command Script.INI
   40209 -r--r--r--     0     0        89 10-Apr-2023 14:54 My Utilities/PSPad editor/PSPad editor/Syntax/CSH Command Script.INI:Zone.Identifier
   40331 -r--r--r--     0     0       971 10-Apr-2023 14:54 My Utilities/PSPad editor/PSPad editor/Syntax/TCSH Command Script.INI
   40331 -r--r--r--     0     0        89 10-Apr-2023 14:54 My Utilities/PSPad editor/PSPad editor/Syntax/TCSH Command Script.INI:Zone.Identifier
guest@porteus:/mnt/sda6$
I see less lines but I don't see an .sh. :unknown: And grep -- '-2023 ' testdisk.log | grep -i .. ".sh "didn't work either.

Going to bed.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5416
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Help! I somehow deleted Windows files that I need

Post#75 by Rava » 16 Oct 2023, 06:54

Ed_P wrote:
16 Oct 2023, 06:46
I see less lines but I don't see an .sh. :unknown: And grep -- '-2023 ' testdisk.log | grep -i .. ".sh "didn't work either.
Could it be you defeated yourself by using Dr. Copy and Mr. Paste?
Why is there a whitespace at the end of grep -i .. ".sh " ?
And what is the ".." meant to be?
Could it be you meant to use a simple | grep ".sh"

Though, be aware that for grep executed likes so the "." in the ".sh" statement is meant as "any character", you have to escape the "." to make grep search for a literal ".".

──────────────────────────────────────────────────────────
Ed_P wrote:
16 Oct 2023, 06:46
Now that this step is resolved do you have any suggestions for my wanting to use multiple selections when reading the log file? I want the -2023 lines plus .sh lines and .jpg lines.
What do you mean by "use multiple selections when reading the log file"

You can add a grep onto a grep:

Code: Select all

grep "Azur Lane" index.txt 
would find all and any entries of "Azur Lane"
Let's presume "index.txt" is created using find and thus has entries like so:

Code: Select all

/Random Folder/whatever.file
/sound/Azur Lane/fan-music.mp3
/video/Azur Lane/Azur Lane 01.mp4
/video/Kantai Collection/Kantai Collection 01.mp4
When you only want to find all entries for "Azur Lane" and "/video/" then you use | and another grep like so:

Code: Select all

grep "Azur Lane" index.txt | grep "/video/" 
When you want to find all "Azur Lane" hits but the "/video/" ones you use -v (Cave! In grep -v is not the same as -V and --version) like so:

Code: Select all

grep "Azur Lane" index.txt | grep -v "/video/" 
And when you want to combine several search patterns use -E like so to find all entries named "Azur Lane" and "Kantai Collection":

Code: Select all

grep -E "Azur Lane|Kantai Collection" index.txt 
Examples:

Code: Select all

guest@rava:/tmp$ cat index.txt 
/Random Folder/whatever.file
/sound/Azur Lane/fan-music.mp3
/video/Azur Lane/Azur Lane 01.mp4
/video/Kantai Collection/Kantai Collection 01.mp4
guest@rava:/tmp$ grep -E "Azur Lane|Kantai Collection" index.txt
/sound/Azur Lane/fan-music.mp3
/video/Azur Lane/Azur Lane 01.mp4
/video/Kantai Collection/Kantai Collection 01.mp4
guest@rava:/tmp$ grep "Azur Lane" index.txt | grep "/video/"
/video/Azur Lane/Azur Lane 01.mp4
guest@rava:/tmp$ grep "Azur Lane" index.txt | grep -v "/video/"
/sound/Azur Lane/fan-music.mp3
guest@rava:/tmp$ 
If none of this is what you meant, please explain what you meant by "use multiple selections when reading the log file".
Cheers!
Yours Rava

Post Reply