Timeline for How to sort filename list (txt-file) by sub-strings of the filename/path with multiple levels. Special challenge: Two types of filename conventions
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 9, 2021 at 13:30 | comment | added | Freddy | Have a look at unix.stackexchange.com/questions/5821. You could overwrite the original file aftwards with awk ... | cut -f5- >newfile && mv -f newfile file) (the first cut example) or use sponge. | |
| Jul 9, 2021 at 9:52 | vote | accept | jaysigg | ||
| Jul 9, 2021 at 9:52 | comment | added | jaysigg | Works perfect, with one exception: What if I just want to overwrite the input file? I tried to use the input filename/path as the output filename/path. But, in contrary to just using the sort command with -o, this led to an empty file!? Thanks again, you both. | |
| Jul 8, 2021 at 20:12 | comment | added | Freddy | To save the output to a new file, use redirection: awk ... | cut -f5- >newfile | |
| Jul 8, 2021 at 8:27 | comment | added | jaysigg | _@Freddy: I tried your solution with the complete file, - sorting works perfectly. The remaining questions is now, how to integrate the creation of a new file or updating the existing file, respectively, with your code. (More just for fun I tried with -o file in the sort-section, but as expected - obviously because of the missing cut-process - this ended up in useless stuff). Would you - or anybody else - have an idea for me? | |
| Jul 8, 2021 at 7:43 | comment | added | jaysigg | Thank you for your efforts. I'm sure both approaches would work fine. But, as I 'feared' to come into the next struggle with a new language as perl would be for me, I preferred to work on with freddy's solution, at least for the moment. I hope you unterstand, @glenn. | |
| Jul 7, 2021 at 15:03 | history | answered | Freddy | CC BY-SA 4.0 |