Bug 212906 - PATCH: awk + grep vs. sed in /usr/share/cluster/ip.sh
PATCH: awk + grep vs. sed in /usr/share/cluster/ip.sh
Product: Red Hat Cluster Suite
Classification: Red Hat
Component: rgmanager (Show other bugs)
All Linux
low Severity low
: ---
: ---
Assigned To: Marek Grac
Cluster QE
Depends On:
  Show dependency treegraph
Reported: 2006-10-29 21:42 EST by Satoru SATOH
Modified: 2009-04-16 16:36 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-11-28 12:31:55 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
grep+awk -> sed patch (987 bytes, patch)
2006-10-29 21:42 EST, Satoru SATOH
no flags Details | Diff

  None (edit)
Description Satoru SATOH 2006-10-29 21:42:27 EST
Description of problem:

It is quite trivial issue, but, there are a few lines, awk+grep combination is
used, found in /usr/share/cluster/ip.sh. I think it may be substituted with sed
(requires less resource and perhaps a little bit faster) such like the following.

## The former is the way found in ip.sh and the later is alternative.
[root@gescom ~]# /sbin/ethtool eth0 | grep "Link detected:" | awk '{print $3;}'
[root@gescom ~]# ethtool eth0 | sed -ne 's/.*Link detected: \(.*\)/\1/p'

## Size of these commands:
[root@foo ~]# cat /etc/redhat-release 
Red Hat Desktop release 4 (Nahant Update 4)
[root@foo ~]# ls -lh /bin/*awk /bin/sed /bin/*grep
lrwxrwxrwx  1 root root    4  6月 29 12:57 /bin/awk -> gawk
lrwxrwxrwx  1 root root    4  8月 14 17:36 /bin/egrep -> grep
lrwxrwxrwx  1 root root    4  8月 14 17:36 /bin/fgrep -> grep
-rwxr-xr-x  1 root root 247K 11月  5  2004 /bin/gawk
-rwxr-xr-x  1 root root  76K  2月 20  2006 /bin/grep
-rwxr-xr-x  1 root root 3.1K 11月  5  2004 /bin/igawk
-rwxr-xr-x  1 root root 248K 11月  5  2004 /bin/pgawk
-rwxr-xr-x  1 root root  46K  4月 14  2006 /bin/sed
[root@foo ~]#

I attached a sample patch, rgmanager-1.9.54_ip.sh_lr.patch.

Version-Release number of selected component (if applicable): rgmanager-1.9.54

How reproducible: always

Steps to Reproduce:
Actual results:

Expected results:

Additional info:
Comment 1 Satoru SATOH 2006-10-29 21:42:27 EST
Created attachment 139691 [details]
grep+awk -> sed patch
Comment 2 Lon Hohberger 2006-11-10 10:55:16 EST
I say 'to-MAY-toes', you say 'to-MAH-toes'.

I'd like to know a clear benefit before I change currently-working code in a
stable release.

It spawns one less process.  However, if it's performance we cared about, we
could use bash shell text parsing to accomplish the same things...

Does it fix a bug?
Comment 3 Lon Hohberger 2006-11-10 10:57:24 EST
Note: I'm cool with putting this in RHCS5 for GA, and backporting to RHCS4 later.
Comment 5 Satoru SATOH 2006-11-27 21:15:24 EST
Excuse me not to give any response for a while.

I'm not sure there are any clear benefits actually. My patch is just another way
to do that and I just thought that less program size and less dependency is
better for HA softwares.
Comment 6 Kiersten (Kerri) Anderson 2006-11-28 12:02:07 EST
devel NAK for rhel4.
Comment 7 RHEL Product and Program Management 2006-11-28 12:31:55 EST
Development Management has reviewed and declined this request.  You may appeal
this decision by reopening this request. 
Comment 8 Marek Grac 2006-11-29 15:37:44 EST
I'm also against changing working code because there are no real benefits. 

Yes, grep + awk is surely slower than sed (2 vs 1 process) but for input as
small as we have from ethtool/ifconfig/ip/... it doesn't matter at all. 

You have to have installed awk anyway

clean code)
Such simple awk commands are easily read by non-awk users but you are right that
this combination should not be used in new RA. 

Note You need to log in before you can comment on or make changes to this bug.