Bug 90001 - inefficient use of awk/grep
inefficient use of awk/grep
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: initscripts (Show other bugs)
9
All Linux
low Severity low
: ---
: ---
Assigned To: Bill Nottingham
Brock Organ
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-04-30 19:35 EDT by Stephen Samuel
Modified: 2014-03-16 22:36 EDT (History)
1 user (show)

See Also:
Fixed In Version: 7.20-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-05-02 12:45:03 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Stephen Samuel 2003-04-30 19:35:43 EDT
Description of problem:
In /etc/sysconfig/network-scripts/ifup line 265:

    NUMDEFROUTES=`ip -o route | \
                  grep "^default" | \
                  awk '{ nlines++ } END { print nlines }'`
This is an inneficient/ silly use of awk. far better to
simply use `wc -c`   (wc is 1/10th the size of awk)

either that, or get rid of grep and change the third line
to: 
                  awk '/^default/{ nlines++ } END { print nlines }'`



Version-Release number of selected component (if applicable):
initscripts-7.14-1

How reproducible:
always

Steps to Reproduce:
1.Read the Source, luke!  (sorry!)
   
Actual results:
It works (a bit inefficient and kludgey, but it works)

Expected results:
elegance

Additional info:
Comment 1 Bill Nottingham 2003-04-30 23:12:13 EDT
The grep needs to go, yes. We can't use wc, it's on /usr.
Comment 2 Bill Nottingham 2003-05-02 12:45:03 EDT
Fixed in CVS, will be in 7.20-1.

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