How does the f argument work in this example of the cut command?
Clash 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?
linux pipe cut
add a comment |Â
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?
linux pipe cut
1
On Linux, just usecat /sys/class/net/enp3s0f2/address
â Stéphane Chazelas
Sep 5 at 10:26
add a comment |Â
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?
linux pipe cut
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
linux pipe cut
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 usecat /sys/class/net/enp3s0f2/address
â Stéphane Chazelas
Sep 5 at 10:26
add a comment |Â
1
On Linux, just usecat /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
add a comment |Â
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
Thank you, that's exactly the answer I needed!
â Sib
Sep 5 at 10:27
add a comment |Â
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.
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
add a comment |Â
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
Thank you, that's exactly the answer I needed!
â Sib
Sep 5 at 10:27
add a comment |Â
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
Thank you, that's exactly the answer I needed!
â Sib
Sep 5 at 10:27
add a comment |Â
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
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
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
add a comment |Â
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
add a comment |Â
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.
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
add a comment |Â
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.
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
add a comment |Â
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.
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.
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
add a comment |Â
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
On Linux, just use
cat /sys/class/net/enp3s0f2/address
â Stéphane Chazelas
Sep 5 at 10:26