how to print interface names only











up vote
1
down vote

favorite












i want to print interface names only from iwconfig command

this is output of iwconfig:



wlp2s0    IEEE 802.11  ESSID:"CoreFragment"  
Mode:Managed Frequency:2.442 GHz Access Point: 0C:D2:B5:55:DF:74
Bit Rate=72.2 Mb/s Tx-Power=22 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:on
Link Quality=55/70 Signal level=-55 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:4 Invalid misc:6567 Missed beacon:0

enp3s0 no wireless extensions.

wlx00e02d01076f IEEE 802.11bgn ESSID:"Aleph_inCar" Nickname:"<WIFI@REALTEK>"
Mode:Master Frequency:2.412 GHz Access Point: 00:E0:2D:01:07:6F
Bit Rate:72.2 Mb/s Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality=4/100 Signal level=4/100 Noise level=0/100
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

lo no wireless extensions.

enx001e101f0000 no wireless extensions.


I tried this :



iwconfig | grep ESSID | sed 's/"//g' | cut -f1  -d" "    


but i got no wireless extension also in output

i want to get output from iwconfig command only

how print wlp2s0,enp3s0,wlx00e02d01076f,enx001e101f0000 only...










share|improve this question









New contributor




yash shah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • yash did you try to pass the interface like wlp2s0 to the ifconfig command?
    – Valentin Bajrami
    2 days ago










  • yes.. I tried but i want to see my output from iwconfig @ValentinBajrami
    – yash shah
    2 days ago






  • 1




    then the easiest way would be iwconfig 2>/dev/null | awk '/ESSID/{print $1}'
    – Valentin Bajrami
    2 days ago






  • 1




    Unclear: You say you don't want the interfaces with no wireless extension, but then you list these in the desired output. What are you going to use the wireless interface names for?
    – Kusalananda
    2 days ago






  • 2




    Ok, so the question changed once again. Do you want lo also in the output? Why would you want enp3s0 in the output. Why does it have to do with wireless interfaces?
    – Valentin Bajrami
    2 days ago















up vote
1
down vote

favorite












i want to print interface names only from iwconfig command

this is output of iwconfig:



wlp2s0    IEEE 802.11  ESSID:"CoreFragment"  
Mode:Managed Frequency:2.442 GHz Access Point: 0C:D2:B5:55:DF:74
Bit Rate=72.2 Mb/s Tx-Power=22 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:on
Link Quality=55/70 Signal level=-55 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:4 Invalid misc:6567 Missed beacon:0

enp3s0 no wireless extensions.

wlx00e02d01076f IEEE 802.11bgn ESSID:"Aleph_inCar" Nickname:"<WIFI@REALTEK>"
Mode:Master Frequency:2.412 GHz Access Point: 00:E0:2D:01:07:6F
Bit Rate:72.2 Mb/s Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality=4/100 Signal level=4/100 Noise level=0/100
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

lo no wireless extensions.

enx001e101f0000 no wireless extensions.


I tried this :



iwconfig | grep ESSID | sed 's/"//g' | cut -f1  -d" "    


but i got no wireless extension also in output

i want to get output from iwconfig command only

how print wlp2s0,enp3s0,wlx00e02d01076f,enx001e101f0000 only...










share|improve this question









New contributor




yash shah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • yash did you try to pass the interface like wlp2s0 to the ifconfig command?
    – Valentin Bajrami
    2 days ago










  • yes.. I tried but i want to see my output from iwconfig @ValentinBajrami
    – yash shah
    2 days ago






  • 1




    then the easiest way would be iwconfig 2>/dev/null | awk '/ESSID/{print $1}'
    – Valentin Bajrami
    2 days ago






  • 1




    Unclear: You say you don't want the interfaces with no wireless extension, but then you list these in the desired output. What are you going to use the wireless interface names for?
    – Kusalananda
    2 days ago






  • 2




    Ok, so the question changed once again. Do you want lo also in the output? Why would you want enp3s0 in the output. Why does it have to do with wireless interfaces?
    – Valentin Bajrami
    2 days ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











i want to print interface names only from iwconfig command

this is output of iwconfig:



wlp2s0    IEEE 802.11  ESSID:"CoreFragment"  
Mode:Managed Frequency:2.442 GHz Access Point: 0C:D2:B5:55:DF:74
Bit Rate=72.2 Mb/s Tx-Power=22 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:on
Link Quality=55/70 Signal level=-55 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:4 Invalid misc:6567 Missed beacon:0

enp3s0 no wireless extensions.

wlx00e02d01076f IEEE 802.11bgn ESSID:"Aleph_inCar" Nickname:"<WIFI@REALTEK>"
Mode:Master Frequency:2.412 GHz Access Point: 00:E0:2D:01:07:6F
Bit Rate:72.2 Mb/s Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality=4/100 Signal level=4/100 Noise level=0/100
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

lo no wireless extensions.

enx001e101f0000 no wireless extensions.


I tried this :



iwconfig | grep ESSID | sed 's/"//g' | cut -f1  -d" "    


but i got no wireless extension also in output

i want to get output from iwconfig command only

how print wlp2s0,enp3s0,wlx00e02d01076f,enx001e101f0000 only...










share|improve this question









New contributor




yash shah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











i want to print interface names only from iwconfig command

this is output of iwconfig:



wlp2s0    IEEE 802.11  ESSID:"CoreFragment"  
Mode:Managed Frequency:2.442 GHz Access Point: 0C:D2:B5:55:DF:74
Bit Rate=72.2 Mb/s Tx-Power=22 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:on
Link Quality=55/70 Signal level=-55 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:4 Invalid misc:6567 Missed beacon:0

enp3s0 no wireless extensions.

wlx00e02d01076f IEEE 802.11bgn ESSID:"Aleph_inCar" Nickname:"<WIFI@REALTEK>"
Mode:Master Frequency:2.412 GHz Access Point: 00:E0:2D:01:07:6F
Bit Rate:72.2 Mb/s Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality=4/100 Signal level=4/100 Noise level=0/100
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

lo no wireless extensions.

enx001e101f0000 no wireless extensions.


I tried this :



iwconfig | grep ESSID | sed 's/"//g' | cut -f1  -d" "    


but i got no wireless extension also in output

i want to get output from iwconfig command only

how print wlp2s0,enp3s0,wlx00e02d01076f,enx001e101f0000 only...







ubuntu network-interface






share|improve this question









New contributor




yash shah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




yash shah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago









Kusalananda

119k16223364




119k16223364






New contributor




yash shah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









yash shah

85




85




New contributor




yash shah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





yash shah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






yash shah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • yash did you try to pass the interface like wlp2s0 to the ifconfig command?
    – Valentin Bajrami
    2 days ago










  • yes.. I tried but i want to see my output from iwconfig @ValentinBajrami
    – yash shah
    2 days ago






  • 1




    then the easiest way would be iwconfig 2>/dev/null | awk '/ESSID/{print $1}'
    – Valentin Bajrami
    2 days ago






  • 1




    Unclear: You say you don't want the interfaces with no wireless extension, but then you list these in the desired output. What are you going to use the wireless interface names for?
    – Kusalananda
    2 days ago






  • 2




    Ok, so the question changed once again. Do you want lo also in the output? Why would you want enp3s0 in the output. Why does it have to do with wireless interfaces?
    – Valentin Bajrami
    2 days ago


















  • yash did you try to pass the interface like wlp2s0 to the ifconfig command?
    – Valentin Bajrami
    2 days ago










  • yes.. I tried but i want to see my output from iwconfig @ValentinBajrami
    – yash shah
    2 days ago






  • 1




    then the easiest way would be iwconfig 2>/dev/null | awk '/ESSID/{print $1}'
    – Valentin Bajrami
    2 days ago






  • 1




    Unclear: You say you don't want the interfaces with no wireless extension, but then you list these in the desired output. What are you going to use the wireless interface names for?
    – Kusalananda
    2 days ago






  • 2




    Ok, so the question changed once again. Do you want lo also in the output? Why would you want enp3s0 in the output. Why does it have to do with wireless interfaces?
    – Valentin Bajrami
    2 days ago
















yash did you try to pass the interface like wlp2s0 to the ifconfig command?
– Valentin Bajrami
2 days ago




yash did you try to pass the interface like wlp2s0 to the ifconfig command?
– Valentin Bajrami
2 days ago












yes.. I tried but i want to see my output from iwconfig @ValentinBajrami
– yash shah
2 days ago




yes.. I tried but i want to see my output from iwconfig @ValentinBajrami
– yash shah
2 days ago




1




1




then the easiest way would be iwconfig 2>/dev/null | awk '/ESSID/{print $1}'
– Valentin Bajrami
2 days ago




then the easiest way would be iwconfig 2>/dev/null | awk '/ESSID/{print $1}'
– Valentin Bajrami
2 days ago




1




1




Unclear: You say you don't want the interfaces with no wireless extension, but then you list these in the desired output. What are you going to use the wireless interface names for?
– Kusalananda
2 days ago




Unclear: You say you don't want the interfaces with no wireless extension, but then you list these in the desired output. What are you going to use the wireless interface names for?
– Kusalananda
2 days ago




2




2




Ok, so the question changed once again. Do you want lo also in the output? Why would you want enp3s0 in the output. Why does it have to do with wireless interfaces?
– Valentin Bajrami
2 days ago




Ok, so the question changed once again. Do you want lo also in the output? Why would you want enp3s0 in the output. Why does it have to do with wireless interfaces?
– Valentin Bajrami
2 days ago










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










Your command works perfectly. Simply redirect the STDERR output to STDOUT, so that grep and cut process them as you want:



iwconfig 2>&1 | grep ESSID | sed 's/"//g' | cut -f1  -d" "  


However, this method using grep, sed and cut is an overkill. A single grep can get you what you want as suggested in the update below.



UDPATE:



As per the edited question, and given that the user is using Ubuntu (and hence the grep supports Perl regex), here is one method:



iwconfig 2>&1 | grep -oP "^w+"





share|improve this answer























  • how I can remove lo from your suggested command :iwconfig 2>&1 | grep -oP "^w+"
    – yash shah
    2 days ago










  • otherwise it works... @shivams
    – yash shah
    2 days ago










  • I think the use of grep , sed and cut is overkill for such a trivial task
    – Valentin Bajrami
    2 days ago










  • @ValentinBajrami Yes. But the combination of the 3 was the one suggested by the OP. I have suggested an updated version.
    – shivams
    2 days ago










  • @yashshah to remove lo, just add one more grep to the pipe: iwconfig 2>&1 | grep -oP "^w+" | grep -v lo
    – shivams
    2 days ago













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: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






yash shah is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f486528%2fhow-to-print-interface-names-only%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










Your command works perfectly. Simply redirect the STDERR output to STDOUT, so that grep and cut process them as you want:



iwconfig 2>&1 | grep ESSID | sed 's/"//g' | cut -f1  -d" "  


However, this method using grep, sed and cut is an overkill. A single grep can get you what you want as suggested in the update below.



UDPATE:



As per the edited question, and given that the user is using Ubuntu (and hence the grep supports Perl regex), here is one method:



iwconfig 2>&1 | grep -oP "^w+"





share|improve this answer























  • how I can remove lo from your suggested command :iwconfig 2>&1 | grep -oP "^w+"
    – yash shah
    2 days ago










  • otherwise it works... @shivams
    – yash shah
    2 days ago










  • I think the use of grep , sed and cut is overkill for such a trivial task
    – Valentin Bajrami
    2 days ago










  • @ValentinBajrami Yes. But the combination of the 3 was the one suggested by the OP. I have suggested an updated version.
    – shivams
    2 days ago










  • @yashshah to remove lo, just add one more grep to the pipe: iwconfig 2>&1 | grep -oP "^w+" | grep -v lo
    – shivams
    2 days ago

















up vote
2
down vote



accepted










Your command works perfectly. Simply redirect the STDERR output to STDOUT, so that grep and cut process them as you want:



iwconfig 2>&1 | grep ESSID | sed 's/"//g' | cut -f1  -d" "  


However, this method using grep, sed and cut is an overkill. A single grep can get you what you want as suggested in the update below.



UDPATE:



As per the edited question, and given that the user is using Ubuntu (and hence the grep supports Perl regex), here is one method:



iwconfig 2>&1 | grep -oP "^w+"





share|improve this answer























  • how I can remove lo from your suggested command :iwconfig 2>&1 | grep -oP "^w+"
    – yash shah
    2 days ago










  • otherwise it works... @shivams
    – yash shah
    2 days ago










  • I think the use of grep , sed and cut is overkill for such a trivial task
    – Valentin Bajrami
    2 days ago










  • @ValentinBajrami Yes. But the combination of the 3 was the one suggested by the OP. I have suggested an updated version.
    – shivams
    2 days ago










  • @yashshah to remove lo, just add one more grep to the pipe: iwconfig 2>&1 | grep -oP "^w+" | grep -v lo
    – shivams
    2 days ago















up vote
2
down vote



accepted







up vote
2
down vote



accepted






Your command works perfectly. Simply redirect the STDERR output to STDOUT, so that grep and cut process them as you want:



iwconfig 2>&1 | grep ESSID | sed 's/"//g' | cut -f1  -d" "  


However, this method using grep, sed and cut is an overkill. A single grep can get you what you want as suggested in the update below.



UDPATE:



As per the edited question, and given that the user is using Ubuntu (and hence the grep supports Perl regex), here is one method:



iwconfig 2>&1 | grep -oP "^w+"





share|improve this answer














Your command works perfectly. Simply redirect the STDERR output to STDOUT, so that grep and cut process them as you want:



iwconfig 2>&1 | grep ESSID | sed 's/"//g' | cut -f1  -d" "  


However, this method using grep, sed and cut is an overkill. A single grep can get you what you want as suggested in the update below.



UDPATE:



As per the edited question, and given that the user is using Ubuntu (and hence the grep supports Perl regex), here is one method:



iwconfig 2>&1 | grep -oP "^w+"






share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago

























answered 2 days ago









shivams

2,86611425




2,86611425












  • how I can remove lo from your suggested command :iwconfig 2>&1 | grep -oP "^w+"
    – yash shah
    2 days ago










  • otherwise it works... @shivams
    – yash shah
    2 days ago










  • I think the use of grep , sed and cut is overkill for such a trivial task
    – Valentin Bajrami
    2 days ago










  • @ValentinBajrami Yes. But the combination of the 3 was the one suggested by the OP. I have suggested an updated version.
    – shivams
    2 days ago










  • @yashshah to remove lo, just add one more grep to the pipe: iwconfig 2>&1 | grep -oP "^w+" | grep -v lo
    – shivams
    2 days ago




















  • how I can remove lo from your suggested command :iwconfig 2>&1 | grep -oP "^w+"
    – yash shah
    2 days ago










  • otherwise it works... @shivams
    – yash shah
    2 days ago










  • I think the use of grep , sed and cut is overkill for such a trivial task
    – Valentin Bajrami
    2 days ago










  • @ValentinBajrami Yes. But the combination of the 3 was the one suggested by the OP. I have suggested an updated version.
    – shivams
    2 days ago










  • @yashshah to remove lo, just add one more grep to the pipe: iwconfig 2>&1 | grep -oP "^w+" | grep -v lo
    – shivams
    2 days ago


















how I can remove lo from your suggested command :iwconfig 2>&1 | grep -oP "^w+"
– yash shah
2 days ago




how I can remove lo from your suggested command :iwconfig 2>&1 | grep -oP "^w+"
– yash shah
2 days ago












otherwise it works... @shivams
– yash shah
2 days ago




otherwise it works... @shivams
– yash shah
2 days ago












I think the use of grep , sed and cut is overkill for such a trivial task
– Valentin Bajrami
2 days ago




I think the use of grep , sed and cut is overkill for such a trivial task
– Valentin Bajrami
2 days ago












@ValentinBajrami Yes. But the combination of the 3 was the one suggested by the OP. I have suggested an updated version.
– shivams
2 days ago




@ValentinBajrami Yes. But the combination of the 3 was the one suggested by the OP. I have suggested an updated version.
– shivams
2 days ago












@yashshah to remove lo, just add one more grep to the pipe: iwconfig 2>&1 | grep -oP "^w+" | grep -v lo
– shivams
2 days ago






@yashshah to remove lo, just add one more grep to the pipe: iwconfig 2>&1 | grep -oP "^w+" | grep -v lo
– shivams
2 days ago












yash shah is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















yash shah is a new contributor. Be nice, and check out our Code of Conduct.













yash shah is a new contributor. Be nice, and check out our Code of Conduct.












yash shah is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f486528%2fhow-to-print-interface-names-only%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Accessing regular linux commands in Huawei's Dopra Linux

Can't connect RFCOMM socket: Host is down

Kernel panic - not syncing: Fatal Exception in Interrupt