Timeline for How to make grep ignore lines without trailing newline character
Current License: CC BY-SA 4.0
16 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 14, 2018 at 18:10 | answer | added | thrig | timeline score: 1 | |
| Jun 13, 2018 at 20:00 | history | tweeted | twitter.com/StackUnix/status/1006989739105415168 | ||
| Jun 13, 2018 at 18:42 | vote | accept | dshin | ||
| Jun 13, 2018 at 18:29 | answer | added | Stéphane Chazelas | timeline score: 3 | |
| Jun 13, 2018 at 18:25 | history | edited | ilkkachu | CC BY-SA 4.0 |
edited title
|
| Jun 13, 2018 at 18:19 | answer | added | ilkkachu | timeline score: 1 | |
| Jun 13, 2018 at 17:58 | answer | added | Arkadiusz Drabczyk | timeline score: 1 | |
| Jun 13, 2018 at 17:43 | comment | added | dshin | @thrig I fork out for performance reasons, as grep can shrink a 10GB file down to 10MB much faster than python can. | |
| Jun 13, 2018 at 17:42 | comment | added | dshin | I use bash as my shell. | |
| Jun 13, 2018 at 17:42 | comment | added | thrig |
do you have to fork out to grep? a high level language can probably detect if a line has a newline on it, and do regular expressions on a line, etc
|
|
| Jun 13, 2018 at 17:41 | comment | added | Arkadiusz Drabczyk |
Oh, ok. We can test if the last character in the file is \n. What shell do you use?
|
|
| Jun 13, 2018 at 17:40 | comment | added | dshin | That might throw out the last line incorrectly. | |
| Jun 13, 2018 at 17:39 | comment | added | Arkadiusz Drabczyk |
Instead of doing grep string FILE do head -n -1 FILE | grep 'string'
|
|
| Jun 13, 2018 at 17:37 | comment | added | dshin | What is the best way to conditionally ignore the last line? | |
| Jun 13, 2018 at 17:37 | comment | added | Arkadiusz Drabczyk |
In practice only the last line can miss \n so maybe it would be enough to ignore last line?
|
|
| Jun 13, 2018 at 17:17 | history | asked | dshin | CC BY-SA 4.0 |