Fedora Linux Support Community & Resources Center
Prev Previous Post   Next Post Next
  #1  
Old 6th May 2012, 06:09 PM
ldelossa Offline
Registered User
 
Join Date: Feb 2012
Location: United States
Posts: 21
windows_7chrome
Help with linux cut command

What's up guys got a quick question,

I'm studying for the linux+ exam and I've come across this command which has me kind of baffled. The command itself is very simple however using it to cut out a section and echo it into the terminal has be kind of confused. Let me explain.

the example has the output of ifconfig which looks like this. I'm trying to extract the hardware address and just have it echo in terminal

$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:76:96:A3:73
inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:76ff:fe96:a373/64 Scope:Link
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7127424 errors:0 dropped:0 overruns:0 frame:0
TX packets:5273519 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6272843708 (5982.2 Mb) TX bytes:1082453585 (1032.3 Mb)
Interrupt:10 Base address:0xde00

The cut command in which I would like to use goes something like this:

$ ifconfig eth0 | grep HWaddr | cut -d “ “ -f 11
00:0C:76:96:A3:73

Now what I'm confused about is why when we set the field switch to 11 (-f 11) does it give us the hardware address we want?? the -d makes a space character the delimiting field but I'm not counting 11 space characters before the hardware address? My intuition would lead me to pass the command

$ ifconfig eth0 | grep HWaddr | cut -d “ “ -f 9 (since I count nine space characters from the begging of hte output to the begging of the hardware address)
00:0C:76:96:A3:73


if anyone can clear this up for me I'd greatly appreciate it.
Reply With Quote
 

Tags
command, cut, linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
linux command Shiva01 Using Fedora 11 22nd September 2009 09:30 PM
Linux SED command help Witlof Using Fedora 8 2nd April 2009 04:18 PM
Linux: GUI vs. Command Line hermouche Linux Chat 19 10th December 2008 01:16 AM
Linux Command for Windows dir s*.* /s Sr Ramitas Using Fedora 6 19th July 2005 11:06 PM


Current GMT-time: 05:46 (Sunday, 26-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat