Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8969023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:32:08+00:00 2026-06-15T17:32:08+00:00

writing a small script to perform house keeping tasks on my servers. I want

  • 0

writing a small script to perform house keeping tasks on my servers.

I want to grab just the X in ethX,

echo `grep -m1 -oE "eth[0-9]*" /etc/network/interfaces | grep -oE [0-9]*`

this works, but I was wondering if someone knew a one time command that can do it, ie a regular experession that can take a word for instance, room456 and only spit out the number.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:32:09+00:00Added an answer on June 15, 2026 at 5:32 pm

    Use positive lookbehind to match any digit string that is preceded by eth:

    $ cat file
    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    
    $ grep -Po '(?<=eth)[0-9]+' file
    0
    1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a small PHP script to grab the latest half dozen Twitter status
I'm currently writing a small script for use on one of our servers using
I just finished writing a small script to combine a lot of png pictures
I am writing a small script for watchr that runs my PHP unit tests.
I am writing a small windows script in javascript/jscript for finding a match for
I'm writing a small C application that launchs a Matlab script (.m file). I
So, I'm writing a chunked file transfer script that is intended to copy files--small
I'm writing small XMPP server using boost::asio and I want to unit-test my code.
I am writing a small script to upload and detect MIME type, using Zend
I am writing a small script to synchronize 2 MySQL tables ( t1 to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.