LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-08-2018, 12:57 PM   #1
crislet01
LQ Newbie
 
Registered: Jan 2018
Posts: 4

Rep: Reputation: Disabled
Display specific text in file


I use sed -n 's/ \+\(eth[0-9]\+\):.*/\1/p' /proc/net/dev | sort to display only all ethX adaptors in a system. typical display would be
eth0
eth1
eth2

on a new system it has just ens160 and ens192 and ens224, how can I adjust the above command to see now only the three ensX

Many thanks
 
Old 01-08-2018, 02:39 PM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
Just replace "eth" with "ens" in the script?
 
Old 01-08-2018, 02:52 PM   #3
crislet01
LQ Newbie
 
Registered: Jan 2018
Posts: 4

Original Poster
Rep: Reputation: Disabled
I did try that already but it did not work.
 
Old 01-08-2018, 03:00 PM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
Perhaps:
Code:
grep -o 'ens[0-9]\+' /proc/net/dev
 
Old 01-08-2018, 07:11 PM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,719

Rep: Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034
If you own the system and prefer the eth naming structure you could also look at:
Quote:
Revert to traditional device names
If you would prefer to retain traditional interface names such as eth0, Predictable Network Interface Names can be disabled by masking the udev rule:

# ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
Alternatively, add net.ifnames=0 to the kernel parameters.
 
Old 01-08-2018, 08:59 PM   #6
crislet01
LQ Newbie
 
Registered: Jan 2018
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks for the replies...

I could revert back to the eth and thanks for the info.. However I'm automating the Linux install and will require ens to be active.

I just need to figure out the sed command to look for all ens entries in the /proc/net/dev file then have them as output...

regards
 
Old 01-08-2018, 09:01 PM   #7
crislet01
LQ Newbie
 
Registered: Jan 2018
Posts: 4

Original Poster
Rep: Reputation: Disabled
Also will not the command grep -o 'ens[0-9]\+' /proc/net/dev only look for ens0, ens1, ens2 etc where they are actually ens160, ens192 and ens224
 
Old 01-08-2018, 09:51 PM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 18,134

Rep: Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927
It will not.
Show the data.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding specific text from a file that is within specific symbols netpumber Linux - Newbie 9 06-19-2014 03:23 PM
How to copy contents of a text file into another file at a specific location andrew777 Linux - General 3 08-04-2013 02:48 PM
Join two specific lines in a text file bfay General 2 03-02-2013 07:41 PM
SED - display text on specific line of text file 3saul Linux - Software 3 12-29-2005 04:32 PM
How to find and change a specific text in a text file by using shell script Bassam Programming 1 07-18-2005 07:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration