Timeline for Grep filenames and use in select menu
Current License: CC BY-SA 4.0
11 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 28, 2020 at 8:08 | vote | accept | bamphe | ||
| Apr 28, 2020 at 8:08 | comment | added | bamphe | Works like a charm! Thank you so much for your thorough explanations and patience with me :) | |
| Apr 27, 2020 at 21:37 | comment | added | terdon♦ | @bamphe I'm an idiot! I added the mapfile and completely forgot the grep! Sorry about that. Try the updated answer. I'm afraid I'm on mobile so I haven't tested it, but it should work. I'll update with an explanation when I'm back at a computer. | |
| Apr 27, 2020 at 21:35 | history | edited | terdon♦ | CC BY-SA 4.0 |
added 69 characters in body
|
| Apr 27, 2020 at 19:07 | comment | added | bamphe | Actually, I realised that options=( $( grep a file) ) already works for the short example. But the problem lies somewhere in the actual script... | |
| Apr 27, 2020 at 18:53 | comment | added | bamphe |
Nice that you replied that quick. Unfortunately I don't really get the meaning of the mapfile, did you forget the filtering in the last step? I tried to put the grep somewhere but this always breaks the code. Now options is just the mapfile of file, right?
|
|
| Apr 27, 2020 at 18:40 | comment | added | terdon♦ | @bamphe heh, R must be the one language whose syntax is even more unpleasantly complicated than the shell's! Anyway, see updated answer. It should work with everything except file names with newlines now. If you need to handle such file names, you will have to change your input file so it is NULL-separated, but that should be a different question. | |
| Apr 27, 2020 at 18:38 | history | edited | terdon♦ | CC BY-SA 4.0 |
added 703 characters in body
|
| Apr 27, 2020 at 18:20 | comment | added | bamphe |
Great, that helps a lot! Especially with the explanation I finally get why you would put extra brackets. Thanks :) However, now I have another problem: all files with a blank space are split into several options, e.g. file with white space.txt would yield options 1) file 2) with 3) white 4) space.txt. Any idea what is wrong here? I made sure that I quoted all variables... (I'm used to write in R and everything seems much more confusing in the shell)
|
|
| Apr 27, 2020 at 17:08 | history | edited | terdon♦ | CC BY-SA 4.0 |
added 645 characters in body
|
| Apr 27, 2020 at 17:00 | history | answered | terdon♦ | CC BY-SA 4.0 |