Timeline for Finding the line number of first occurrence of a text in bash script
Current License: CC BY-SA 4.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 2, 2022 at 19:32 | comment | added | lauhub | @DanieleGrassini that is correct, thank you, I corrected my answer | |
| Jul 2, 2022 at 19:31 | history | edited | lauhub | CC BY-SA 4.0 | correction: head instead of tail |
| Jul 1, 2022 at 17:15 | comment | added | DanieleGrassini | Why pipe to tail? The OP need the first so it should be head. Also note that ... | head -1 | sed '...' can be done with just sed as well : ... | sed '1s/:.*//;q' | |
| Jul 1, 2022 at 14:40 | comment | added | DanieleGrassini | Why pass grep output to cut? If the result need to be saved in a variable i think is better to use parameters expansion: lineno=$(grep -m1 -n -- '^c' "${varFileLog}");lineno="${lineno%%:*}" | |
| Jun 27, 2022 at 12:15 | comment | added | Ed Morton | upvoted for the awk answer. I wouldn't bother with the rest as they're all inferior to that one in terms of conciseness and/or portability and/or efficiency. | |
| Jun 27, 2022 at 10:21 | history | edited | lauhub | CC BY-SA 4.0 | filename with =s is another problem, double dash too: how to learn from mistakes if there are no mistake |
| Jun 27, 2022 at 6:59 | history | edited | Stéphane Chazelas | CC BY-SA 4.0 | added missing --, use redirection in awk to avoid problems with filenames with =s. Use standard -n1 instead of deprecated -1 |
| Jun 24, 2022 at 9:04 | history | answered | lauhub | CC BY-SA 4.0 |