0

I have a music library that I am trying to restore from backup.

The original source library was on a QNAP NAS and I copied it over to a CentOS system without any problems.

Now that I am trying to copy the files back, the QNAP NAS generated a whole bunch of hidden directories (called ".@__thumbs").

I used find -name .@__thumbs > results.sh and I want to remove those hidden folders as I am restoring the data back to my NAS.

The problem that I am running into is that the folders for the music albums sometimes will either have parenthesis or square brackets for the year, so when I try to remove, for example: rm -rf "some album (2009)/.@__thumbs" or rm -rf "some other album [2010]/.@__thumbs", bash gives me an error:

./results.sh: command substitution: line 2: unexpected EOF while looking for matching `''
./results.sh: command substitution: line 3: syntax error: unexpected end of file
./results.sh: command substitution: line 19: syntax error near unexpected token `('

So how do I work around that in the context of bash shell scripting?

(I'm not a programmer nor a developer, so do forgive me for my dumb question.)

Your help is greatly appreciated.

Thank you.

edit

@Kusalananda Since you closed this, I had to edit my original question.

  1. re: "Consider adding the actual commands that generate those errors to the question. Without them, your question is unclear, and we may only speculate."

I did.

Read my original question again, most notably here: "The problem that I am running into is that the folders for the music albums sometimes will either have parenthesis or square brackets for the year, so when I try to remove, for example: rm -rf "some album (2009)/.@__thumbs" or rm -rf "some other album [2010]/.@__thumbs", bash gives me an error:"

  1. re: duplicate question I tried running the search specifically for posts containing "exact file name" and there weren't any questions (nor answers) that were obvious in regards to what I am trying to do here.

The reason why people appear to ask duplicate questions is because they don't know what you know. Therefore; I wouldn't have even known to ask the question the way that you're asking them, and therefore; would not have entered those search terms.

I read through both of the duplicate questions that you have provided the links to and after reading through the entirety of both threads, I still wouldn't have been able to piece together the answer that @cas provided.

For example, I am now needing to use the non-GNU solution (even though I am using it in CentOS, ironically), because it is now complaining that the find -name @.thumb -delete command -- it says that those directories aren't empty, and so, I find myself needing to use the non-GNU solution to deal with that instead.

Again, even after reading both of the linked, duplicate questions, I would not have pieced that together in the same way that @cas was able to provide the answer to my question.

Developers and regular sysadmins would've probably been able to piece it together. For everybody else, I wouldn't necessarily assume that. (Or maybe I'm just dumb because I couldn't piece it together and figure it out.)

  • 1
    Without seeing your script, it's impossible to tell exactly what is going wrong on lines 2, 3, and 19. I'd guess you're trying to process the output of find in a for or while ... read loop (which is never a good idea). But you're probably over-complicating things - if you're using GNU find (which is standard on Linux), you can just run find -name .@__thumbs -delete to delete the unwanted directories. On non-GNU find, find -name .@__thumbs -exec rm -rf {} + – cas Sep 08 '22 at 04:05
  • Thank you. The script is really simple.

    The output on the find -name .@__thumbs command would normally print out all of the places where it found those directories and then what I did was I just took that output file (results.sh) and then wrapped rm -rf " in front of the results and replaced thumb with thumb" to close off that command.

    But I'll try your suggestion to see if that works. Thank you.

    – alpha754293 Sep 08 '22 at 05:09
  • Oh yay! Looks like that worked! Thank you! – alpha754293 Sep 08 '22 at 05:13
  • Consider adding the actual commands that generate those errors to the question. Without them, your question is unclear, and we may only speculate. – Kusalananda Sep 08 '22 at 05:56
  • 1
    Looking at your comments, it seems like your question is a duplicate of either of two questions or of both: Why is looping over find's output bad practice? When is double-quoting necessary? ... and from your explicit description, I'm going with the first. – Kusalananda Sep 08 '22 at 05:58

0 Answers0