how to print interface names only

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











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























  • yash did you try to pass the interface like wlp2s0 to the ifconfig command?
    – Valentin Bajrami
    Dec 7 at 8:22










  • yes.. I tried but i want to see my output from iwconfig @ValentinBajrami
    – yash shah
    Dec 7 at 8:27






  • 1




    then the easiest way would be iwconfig 2>/dev/null | awk '/ESSID/print $1'
    – Valentin Bajrami
    Dec 7 at 8:37






  • 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
    Dec 7 at 8:40






  • 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
    Dec 7 at 8:40














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























  • yash did you try to pass the interface like wlp2s0 to the ifconfig command?
    – Valentin Bajrami
    Dec 7 at 8:22










  • yes.. I tried but i want to see my output from iwconfig @ValentinBajrami
    – yash shah
    Dec 7 at 8:27






  • 1




    then the easiest way would be iwconfig 2>/dev/null | awk '/ESSID/print $1'
    – Valentin Bajrami
    Dec 7 at 8:37






  • 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
    Dec 7 at 8:40






  • 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
    Dec 7 at 8:40












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















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















share|improve this question













share|improve this question




share|improve this question








edited Dec 7 at 8:36









Kusalananda

120k16225369




120k16225369










asked Dec 7 at 8:02









yash shah

105




105











  • yash did you try to pass the interface like wlp2s0 to the ifconfig command?
    – Valentin Bajrami
    Dec 7 at 8:22










  • yes.. I tried but i want to see my output from iwconfig @ValentinBajrami
    – yash shah
    Dec 7 at 8:27






  • 1




    then the easiest way would be iwconfig 2>/dev/null | awk '/ESSID/print $1'
    – Valentin Bajrami
    Dec 7 at 8:37






  • 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
    Dec 7 at 8:40






  • 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
    Dec 7 at 8:40
















  • yash did you try to pass the interface like wlp2s0 to the ifconfig command?
    – Valentin Bajrami
    Dec 7 at 8:22










  • yes.. I tried but i want to see my output from iwconfig @ValentinBajrami
    – yash shah
    Dec 7 at 8:27






  • 1




    then the easiest way would be iwconfig 2>/dev/null | awk '/ESSID/print $1'
    – Valentin Bajrami
    Dec 7 at 8:37






  • 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
    Dec 7 at 8:40






  • 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
    Dec 7 at 8:40















yash did you try to pass the interface like wlp2s0 to the ifconfig command?
– Valentin Bajrami
Dec 7 at 8:22




yash did you try to pass the interface like wlp2s0 to the ifconfig command?
– Valentin Bajrami
Dec 7 at 8:22












yes.. I tried but i want to see my output from iwconfig @ValentinBajrami
– yash shah
Dec 7 at 8:27




yes.. I tried but i want to see my output from iwconfig @ValentinBajrami
– yash shah
Dec 7 at 8:27




1




1




then the easiest way would be iwconfig 2>/dev/null | awk '/ESSID/print $1'
– Valentin Bajrami
Dec 7 at 8:37




then the easiest way would be iwconfig 2>/dev/null | awk '/ESSID/print $1'
– Valentin Bajrami
Dec 7 at 8:37




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
Dec 7 at 8:40




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
Dec 7 at 8:40




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
Dec 7 at 8:40




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
Dec 7 at 8:40










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
    Dec 7 at 9:27










  • otherwise it works... @shivams
    – yash shah
    Dec 7 at 9:28










  • I think the use of grep , sed and cut is overkill for such a trivial task
    – Valentin Bajrami
    Dec 7 at 9:39










  • @ValentinBajrami Yes. But the combination of the 3 was the one suggested by the OP. I have suggested an updated version.
    – shivams
    Dec 7 at 14:54










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











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
);



);













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
    Dec 7 at 9:27










  • otherwise it works... @shivams
    – yash shah
    Dec 7 at 9:28










  • I think the use of grep , sed and cut is overkill for such a trivial task
    – Valentin Bajrami
    Dec 7 at 9:39










  • @ValentinBajrami Yes. But the combination of the 3 was the one suggested by the OP. I have suggested an updated version.
    – shivams
    Dec 7 at 14:54










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















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
    Dec 7 at 9:27










  • otherwise it works... @shivams
    – yash shah
    Dec 7 at 9:28










  • I think the use of grep , sed and cut is overkill for such a trivial task
    – Valentin Bajrami
    Dec 7 at 9:39










  • @ValentinBajrami Yes. But the combination of the 3 was the one suggested by the OP. I have suggested an updated version.
    – shivams
    Dec 7 at 14:54










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













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 Dec 7 at 14:55

























answered Dec 7 at 8:22









shivams

2,86611425




2,86611425











  • how I can remove lo from your suggested command :iwconfig 2>&1 | grep -oP "^w+"
    – yash shah
    Dec 7 at 9:27










  • otherwise it works... @shivams
    – yash shah
    Dec 7 at 9:28










  • I think the use of grep , sed and cut is overkill for such a trivial task
    – Valentin Bajrami
    Dec 7 at 9:39










  • @ValentinBajrami Yes. But the combination of the 3 was the one suggested by the OP. I have suggested an updated version.
    – shivams
    Dec 7 at 14:54










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

















  • how I can remove lo from your suggested command :iwconfig 2>&1 | grep -oP "^w+"
    – yash shah
    Dec 7 at 9:27










  • otherwise it works... @shivams
    – yash shah
    Dec 7 at 9:28










  • I think the use of grep , sed and cut is overkill for such a trivial task
    – Valentin Bajrami
    Dec 7 at 9:39










  • @ValentinBajrami Yes. But the combination of the 3 was the one suggested by the OP. I have suggested an updated version.
    – shivams
    Dec 7 at 14:54










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
















how I can remove lo from your suggested command :iwconfig 2>&1 | grep -oP "^w+"
– yash shah
Dec 7 at 9:27




how I can remove lo from your suggested command :iwconfig 2>&1 | grep -oP "^w+"
– yash shah
Dec 7 at 9:27












otherwise it works... @shivams
– yash shah
Dec 7 at 9:28




otherwise it works... @shivams
– yash shah
Dec 7 at 9:28












I think the use of grep , sed and cut is overkill for such a trivial task
– Valentin Bajrami
Dec 7 at 9:39




I think the use of grep , sed and cut is overkill for such a trivial task
– Valentin Bajrami
Dec 7 at 9:39












@ValentinBajrami Yes. But the combination of the 3 was the one suggested by the OP. I have suggested an updated version.
– shivams
Dec 7 at 14:54




@ValentinBajrami Yes. But the combination of the 3 was the one suggested by the OP. I have suggested an updated version.
– shivams
Dec 7 at 14:54












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





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


















draft saved

draft discarded
















































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

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?