Le ven. 6 mars 2026 à 17:41, Laurent Lyaudet
<[email protected]> a écrit :
>
> Thanks for your answers :)
>
> Le jeu. 5 mars 2026 à 20:56, Paul Eggert <[email protected]> a écrit :
> > That implementation should use cmp -s, instead of calling wc twice,
> > since it's possible for the output of grep to differ from its input even
> > though both contain the same number of newlines.
>
> Since you suggested to use cmp -s,
> I will test it and see if at least my code can be made bug free when
> other options are supplied
> to the command grep inside my function.
>
I did some testing.
cmp and diff seems to have marginal differences in performance.
But I'm glad to know that there is cmp to have a truly silent diff.
I also tested both of my bash functions:
  in_place_grep
with 2 calls to wc
and
  in_place_grep2
with one call to cmp.
Using random files of slightly more than 13MB,
in_place_grep is at most faster by 1 millisecond
for a total time between 26 milliseconds and 79 milliseconds
depending if my test grep some lines at random
or grep all lines except the last one.
So clearly, cmp is a better way to use in the code my function.
Thanks :)



Reply via email to