Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'can be simplified' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
can be simplified
Authored by: hayne on Jan 31, '02 09:13:20AM
The first line can be simplified to:
if ! ifconfig -a | grep -q 'status: active'

The -q option to grep makes it run quietly (i.e no output)

If you wanted to make it a bit more robust against possible changes
in the output format of ifconfig, you could use:
if ! ifconfig -a | grep -q 'status:[ \t]*active'

to allow for arbitrary spaces and tabs.

[ Reply to This | # ]
can be simplified
Authored by: Anonymous on Jan 31, '02 07:07:59PM

That was boneheaded on my part. I was trying another way of parsing stuff out, and it didn't work, so I just parsed for active, but it was late and I wasn't thinking :)

Thanks for the correction



[ Reply to This | # ]