shell - fgrep or grep -F, which one is better for portable script? -
i having controversial commentary on this answer question whether should use fgrep or grep -f
switch (i.e grep -f
) portability. points have been came light far are:
grep -f
:
- is posix standard.
- gnu
grep
has declaredfgrep
deprecated.
fgrep
:
- historically came before
grep -f
option. - even though gnu grep declared
fgrep
deprecated, seem stick historical use.
if consider old (really old) systems, can find of them not having grep -f
in them (and think chance of happening rare). need worry very old machines , avoid posix standard that!!
if think current situation , include old machines (which supposedly/allegedly don't have grep -f
), there more systems supporting fgrep
.
on other hand, if future, fgrep
going history , grep -f
triumph upon posix standard.
and isn't accepted practice use posix standard better portability?
this question bit opinion based. i'd put 2 cents here :-
as mentioned fgrep
going history , grep -f
posix standard, permitting ok(for preserving legacy codes); using fgrep in view totally absurd.
those users can easily persuaded download new version of gnu grep the official gnu grep project page. in system version of grep 2.20(linux - centos 7; kernel - 3.10).
so, i'd present 2 reasons :-
newer software versions released purpose --- improve previous version , remove kind of bugs,etc. so, here gnu grep recommends use
grep -f
posix standard.and, downloading , installing new version of software not complex task. doesn't require extra new library or dependency, better version kinds of search, removes liability of using
fgrep
anymore.
sticking older ideas preserve legacy codes point against it, but, again future usages 1 should stick posix standard , use grep -f
.
Comments
Post a Comment