![]() ![]() OLDEST:… and you will be able to tell it's a SUBFOLDER_* line. If a subdirectory is named OLDEST:…, it will appear as. ![]() We don't need - later in cd "$d" (more info: Filenames with leading dashes).* (in case you want hidden directories), note it will match. Remember * does not match names starting with a dot. */ means we're iterating over directories (and symlinks to directories). We use a subshell ( ( )), so the scope of cd is limited. You don't need to run the code as a script, you don't need to run it strictly in sh, you can paste it into an interactive POSIX-compliant shell (e.g. I mean the shell code alone, the tools do use non-portable extensions. The shebang #!/bin/sh is to indicate the shell code is portable. If you want to parse the output further, do it before tr and keep in mind you're dealing with null-terminated lines.įind. (and then you know it's your SUBFOLDER_* line) or with OLDEST:/ NEWEST. After the conversion the output may be ambiguous (because of newlines in filenames), but before the conversion it's not: each null-terminated line either begins with. ![]() Data is processed as null-terminated strings until finally tr converts nulls to newlines, so the output looks good¹ in a terminal. The following code is designed to handle all filenames (including filenames with newlines) reliably. This answer uses GNU find, GNU sort and GNU sed it is not portable. I assume this is GNU find and other tools in your OS also support GNU extensions. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |