How does the f argument work in this example of the cut command?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm studying for the LPIC-1 exam and I'm stuck understanding the following example of the command cut:



ifconfig enp3s0f2 produces the following result:



enp3s0f2: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:90:f5:e5:e4:7c txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


I then run the command ifconfig enp3s0f2 | grep ether | cut -d " " -f 10 which displays this output, as I want to isolate the MAC address: 00:90:f5:e5:e4:7c



However, I only played around with the -f parameter which has 10 as a value. I don't understand why it's 10 and not another number. I've looked at several pages with examples on how to use the cut command and the different arguments, but in this example, it doesn't make sense at all to me.



How to isolate this MAC address it should be the value 10 to be assigned to -f?










share|improve this question



















  • 1




    On Linux, just use cat /sys/class/net/enp3s0f2/address
    – Stéphane Chazelas
    Sep 5 at 10:26














up vote
0
down vote

favorite












I'm studying for the LPIC-1 exam and I'm stuck understanding the following example of the command cut:



ifconfig enp3s0f2 produces the following result:



enp3s0f2: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:90:f5:e5:e4:7c txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


I then run the command ifconfig enp3s0f2 | grep ether | cut -d " " -f 10 which displays this output, as I want to isolate the MAC address: 00:90:f5:e5:e4:7c



However, I only played around with the -f parameter which has 10 as a value. I don't understand why it's 10 and not another number. I've looked at several pages with examples on how to use the cut command and the different arguments, but in this example, it doesn't make sense at all to me.



How to isolate this MAC address it should be the value 10 to be assigned to -f?










share|improve this question



















  • 1




    On Linux, just use cat /sys/class/net/enp3s0f2/address
    – Stéphane Chazelas
    Sep 5 at 10:26












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm studying for the LPIC-1 exam and I'm stuck understanding the following example of the command cut:



ifconfig enp3s0f2 produces the following result:



enp3s0f2: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:90:f5:e5:e4:7c txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


I then run the command ifconfig enp3s0f2 | grep ether | cut -d " " -f 10 which displays this output, as I want to isolate the MAC address: 00:90:f5:e5:e4:7c



However, I only played around with the -f parameter which has 10 as a value. I don't understand why it's 10 and not another number. I've looked at several pages with examples on how to use the cut command and the different arguments, but in this example, it doesn't make sense at all to me.



How to isolate this MAC address it should be the value 10 to be assigned to -f?










share|improve this question















I'm studying for the LPIC-1 exam and I'm stuck understanding the following example of the command cut:



ifconfig enp3s0f2 produces the following result:



enp3s0f2: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:90:f5:e5:e4:7c txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


I then run the command ifconfig enp3s0f2 | grep ether | cut -d " " -f 10 which displays this output, as I want to isolate the MAC address: 00:90:f5:e5:e4:7c



However, I only played around with the -f parameter which has 10 as a value. I don't understand why it's 10 and not another number. I've looked at several pages with examples on how to use the cut command and the different arguments, but in this example, it doesn't make sense at all to me.



How to isolate this MAC address it should be the value 10 to be assigned to -f?







linux pipe cut






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 5 at 17:56









Rui F Ribeiro

36.8k1273117




36.8k1273117










asked Sep 5 at 10:14









Sib

31




31







  • 1




    On Linux, just use cat /sys/class/net/enp3s0f2/address
    – Stéphane Chazelas
    Sep 5 at 10:26












  • 1




    On Linux, just use cat /sys/class/net/enp3s0f2/address
    – Stéphane Chazelas
    Sep 5 at 10:26







1




1




On Linux, just use cat /sys/class/net/enp3s0f2/address
– Stéphane Chazelas
Sep 5 at 10:26




On Linux, just use cat /sys/class/net/enp3s0f2/address
– Stéphane Chazelas
Sep 5 at 10:26










2 Answers
2






active

oldest

votes

















up vote
4
down vote



accepted










This is because of the delimiter which we use, we have 8 spaces before ether



We can check by using the below code.



 ifconfig enp3s0f2 | grep ether | sed 's/ether.*//' |grep -o ' ' | wc -l 

8


So the 9th field is ether and 10th field is 00:90:f5:e5:e4:7c






share|improve this answer




















  • Thank you, that's exactly the answer I needed!
    – Sib
    Sep 5 at 10:27

















up vote
1
down vote













From man cut:



 -d, --delimiter=DELIM
use DELIM instead of TAB for field delimiter

-f, --fields=LIST
select only these fields; also print any line that contains no delimiter character, unless the -s option is specified


So you're splitting the output by every delimiting character, in your case a space. This produces an array of fields. The -f option tells cut to only return the 10th field.






share|improve this answer




















  • Hi, Thanks but this doesn't help understand how the MAC address is considered the 10th field based on what was piped, even with the delimiting character being a space. Am I understanding something wrong? Aren't the fields being counted from the word "ether", which would be the first one? If yes, how can the MAC address be the 10th?
    – Sib
    Sep 5 at 10:25










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f466977%2fhow-does-the-f-argument-work-in-this-example-of-the-cut-command%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
4
down vote



accepted










This is because of the delimiter which we use, we have 8 spaces before ether



We can check by using the below code.



 ifconfig enp3s0f2 | grep ether | sed 's/ether.*//' |grep -o ' ' | wc -l 

8


So the 9th field is ether and 10th field is 00:90:f5:e5:e4:7c






share|improve this answer




















  • Thank you, that's exactly the answer I needed!
    – Sib
    Sep 5 at 10:27














up vote
4
down vote



accepted










This is because of the delimiter which we use, we have 8 spaces before ether



We can check by using the below code.



 ifconfig enp3s0f2 | grep ether | sed 's/ether.*//' |grep -o ' ' | wc -l 

8


So the 9th field is ether and 10th field is 00:90:f5:e5:e4:7c






share|improve this answer




















  • Thank you, that's exactly the answer I needed!
    – Sib
    Sep 5 at 10:27












up vote
4
down vote



accepted







up vote
4
down vote



accepted






This is because of the delimiter which we use, we have 8 spaces before ether



We can check by using the below code.



 ifconfig enp3s0f2 | grep ether | sed 's/ether.*//' |grep -o ' ' | wc -l 

8


So the 9th field is ether and 10th field is 00:90:f5:e5:e4:7c






share|improve this answer












This is because of the delimiter which we use, we have 8 spaces before ether



We can check by using the below code.



 ifconfig enp3s0f2 | grep ether | sed 's/ether.*//' |grep -o ' ' | wc -l 

8


So the 9th field is ether and 10th field is 00:90:f5:e5:e4:7c







share|improve this answer












share|improve this answer



share|improve this answer










answered Sep 5 at 10:23









msp9011

3,46643862




3,46643862











  • Thank you, that's exactly the answer I needed!
    – Sib
    Sep 5 at 10:27
















  • Thank you, that's exactly the answer I needed!
    – Sib
    Sep 5 at 10:27















Thank you, that's exactly the answer I needed!
– Sib
Sep 5 at 10:27




Thank you, that's exactly the answer I needed!
– Sib
Sep 5 at 10:27












up vote
1
down vote













From man cut:



 -d, --delimiter=DELIM
use DELIM instead of TAB for field delimiter

-f, --fields=LIST
select only these fields; also print any line that contains no delimiter character, unless the -s option is specified


So you're splitting the output by every delimiting character, in your case a space. This produces an array of fields. The -f option tells cut to only return the 10th field.






share|improve this answer




















  • Hi, Thanks but this doesn't help understand how the MAC address is considered the 10th field based on what was piped, even with the delimiting character being a space. Am I understanding something wrong? Aren't the fields being counted from the word "ether", which would be the first one? If yes, how can the MAC address be the 10th?
    – Sib
    Sep 5 at 10:25














up vote
1
down vote













From man cut:



 -d, --delimiter=DELIM
use DELIM instead of TAB for field delimiter

-f, --fields=LIST
select only these fields; also print any line that contains no delimiter character, unless the -s option is specified


So you're splitting the output by every delimiting character, in your case a space. This produces an array of fields. The -f option tells cut to only return the 10th field.






share|improve this answer




















  • Hi, Thanks but this doesn't help understand how the MAC address is considered the 10th field based on what was piped, even with the delimiting character being a space. Am I understanding something wrong? Aren't the fields being counted from the word "ether", which would be the first one? If yes, how can the MAC address be the 10th?
    – Sib
    Sep 5 at 10:25












up vote
1
down vote










up vote
1
down vote









From man cut:



 -d, --delimiter=DELIM
use DELIM instead of TAB for field delimiter

-f, --fields=LIST
select only these fields; also print any line that contains no delimiter character, unless the -s option is specified


So you're splitting the output by every delimiting character, in your case a space. This produces an array of fields. The -f option tells cut to only return the 10th field.






share|improve this answer












From man cut:



 -d, --delimiter=DELIM
use DELIM instead of TAB for field delimiter

-f, --fields=LIST
select only these fields; also print any line that contains no delimiter character, unless the -s option is specified


So you're splitting the output by every delimiting character, in your case a space. This produces an array of fields. The -f option tells cut to only return the 10th field.







share|improve this answer












share|improve this answer



share|improve this answer










answered Sep 5 at 10:21









Panki

1739




1739











  • Hi, Thanks but this doesn't help understand how the MAC address is considered the 10th field based on what was piped, even with the delimiting character being a space. Am I understanding something wrong? Aren't the fields being counted from the word "ether", which would be the first one? If yes, how can the MAC address be the 10th?
    – Sib
    Sep 5 at 10:25
















  • Hi, Thanks but this doesn't help understand how the MAC address is considered the 10th field based on what was piped, even with the delimiting character being a space. Am I understanding something wrong? Aren't the fields being counted from the word "ether", which would be the first one? If yes, how can the MAC address be the 10th?
    – Sib
    Sep 5 at 10:25















Hi, Thanks but this doesn't help understand how the MAC address is considered the 10th field based on what was piped, even with the delimiting character being a space. Am I understanding something wrong? Aren't the fields being counted from the word "ether", which would be the first one? If yes, how can the MAC address be the 10th?
– Sib
Sep 5 at 10:25




Hi, Thanks but this doesn't help understand how the MAC address is considered the 10th field based on what was piped, even with the delimiting character being a space. Am I understanding something wrong? Aren't the fields being counted from the word "ether", which would be the first one? If yes, how can the MAC address be the 10th?
– Sib
Sep 5 at 10:25

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f466977%2fhow-does-the-f-argument-work-in-this-example-of-the-cut-command%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?