Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

10
  • Hi Freddy, I noticed that the ${file%%/*} sometimes work and sometimes it doesn't! Commented Apr 14, 2020 at 15:26
  • Sometimes, I get empty folder name! Commented Apr 14, 2020 at 15:33
  • What is the pattern for the file path when the folder name is empty? Commented Apr 14, 2020 at 15:37
  • I would say e.g. jk-z30-t50-k001-za*/file.txt intead of Folder*/file.txt! Commented Apr 14, 2020 at 15:40
  • Hm, that looks okay. I thought you might have a folder with a subfolder like Folder/subdir*/file.txt where you would need the shortest pattern ${file%/*} to get Folder/subdirx instead of Folder as result. Have you checked the output of echo "file=$file, folder=${file%%/*}" in the loop? Commented Apr 14, 2020 at 15:56