Bug 90001 - inefficient use of awk/grep
Summary: inefficient use of awk/grep
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: initscripts
Version: 9
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-04-30 23:35 UTC by Stephen Samuel
Modified: 2014-03-17 02:36 UTC (History)
1 user (show)

Fixed In Version: 7.20-1
Clone Of:
Environment:
Last Closed: 2003-05-02 16:45:03 UTC
Embargoed:


Attachments (Terms of Use)

Description Stephen Samuel 2003-04-30 23:35:43 UTC
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-05-01 03:12:13 UTC
The grep needs to go, yes. We can't use wc, it's on /usr.

Comment 2 Bill Nottingham 2003-05-02 16:45:03 UTC
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.