I work with a proof-reader whom I pay certain sum per each N characters (like 500000). He (usually) creates/edits files in alphabetical order. Content/filenames are in (non-latin) utf-8. Simple plain text markdown (.md) or org (.org) files.
I need to find an efficient way to note for myself his "N characters milestones", so that I know when to pay him. For the sake of example, let's say I paid him last time till the character number 3036 in the file "aab.md". He finished that file, went on with "aac.md", "aad.md" and is now on "csdw.md".
- How can I "measure" N characters (everything included: punctuation, spaces, digits, newlines, braces, etc) within that stream (assuming all of them reside in the same directory)? I.e. I need a bash command that will get "aab.md", 3036, and N as input and provide something like: "csaw.md", 5023 (meaning that N chars ended in that file on that exact letter).
- How can I list the files, that were accounted for in the previous command?
- It's less important, but if possible - how will the command from #1 look like, if the files are spread over several directories (also in alphabetical order), like he stopped last time on the character 3036 in the file "a/aab.md" and is now on "np/csdw.md"?
I figured out that
cat * | wc -m can provide amount of chars in all the files, but it is still far away from what I need.