Looking for a linux command line solution

This is child-like I am sure, as all things are once you know the answer.  I have never needed to do much on the command line besides the usual.  I am curious if there is a way to do this simple task without writing an actual script...

I do this:

grep 'BOOTPROTO' /etc/sysconfig/network/ifcfg-eth0

Open in new window

I get this:


Open in new window

I need this:


Open in new window

I thought awk would be easy, but the lack of spaces in the result shut that idea down.  I have no idea how to trim this out via command line.  Maybe there is a command to return only that between the single quotes or some such.  Maybe a regular expression?  Not my area.  Hoping this can be my 'one new thing' for today...

Who is Participating?
Dave GouldConnect With a Mentor Onsite SupportCommented:
grep 'BOOTPROTO' /etc/sysconfig/network/ifcfg-eth0 | awk -F= '{print $2}' will give you

'static' but leave the single quotes

However, you could try

grep 'BOOTPROTO' /etc/sysconfig/network/ifcfg-eth0 |awk -F\' '{print $2}'

-F = use the following as a field separator. The \ is to escape the single quote so that it is not interpreted as a special char.
Owen_ParkerAuthor Commented:
Splendid  trappa01!  The explanation is much more valuable than the answer!  I have never used awk per se, but have seen it used many times by my resident engineer/Linux guru I usually push this stuff to.  I'll review better the options now that i know better the possibilities.
Owen_ParkerAuthor Commented:
Perfectly explained final answer...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.