4 ms·
I mean, if you knew you only wanted to find/replace on line 4, why not simply stop the search after the first match? The syntax escapes me at the moment, but I
by filleduchaos 3y ago
I mean, if you knew you only wanted to find/replace on line 4, why not simply stop the search after the first match?
The syntax escapes me at the moment, but I'm quite sure I've used sed (or maybe awk?) in the past to do exactly that
- PetahNZ 3y agoSed takes ages to remove a single line from huge files too.
- nickjj 3y agoAs far as I know sed will still read and write the full file, even when you do a modification on a specific line. I've target deleted 1 line with sed and it took quite some time too.
- filleduchaos 3y agoThere's a big difference between "quite some time" and 30 minutes, though. Of course sed needs to read the file and write it back to disk, but that's capped by I/O speed which is very high on modern drives - we're talking seconds for a file in the tens of gigabytes on the fastest SSDs, a very far cry from half an entire hour.
- nickjj 3y agoThis was run on an AWS gp3 SSD EBS volume with 3k IOPS. It was a CPU optimized c6i.xlarge machine. The file in question was 200 GB. I used "quite some time" because this happened months ago and I don't recall the exact time on the delete. I don't think deleting a line was any faster than doing a find / replace on 1 line. If sed is reading and writing the file in both cases I'd expect both to have the same performance.