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 8399643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:21:34+00:00 2026-06-09T21:21:34+00:00

I have folders named: example1 example2 example3 And I want to extract the example

  • 0

I have folders named:

example1 example2 example3

And I want to extract the example number from each of them. Something like:

for exampleSubfolder in `find . -type d`
do
  example_number= #replace 'example' in $exampleSubfolder with empty string
  #do other stuff in this subfolder
done

Any simple way to do this?

  • 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-09T21:21:35+00:00Added an answer on June 9, 2026 at 9:21 pm

    If you only need the number:

    find . -type d -name 'example*' | egrep -o "[0-9]+"
    

    But if you want to know the correspondance between folder name and number:

    for f in $(find . -mindepth 1 -maxdepth 1 -type d -name 'example*')
    do
       number=${f#example}
    done
    

    Updated with the string replace bashism.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two domain names www.example1.com www.example2.com When these come into tomcat I want
In the /data directory of solr, suppose, I have three folders named as index,
I have a page in HTML(index.html), and a folders named images, css, js that
I have a folder named repository in my admin folders. This folder holds 2
I have a folder named img and i want to use js to look
I have a folder in my app named Files. I would like to display
Example: I have the following JSON object. {currentVersion : 10.0, folders : [], services
I have a mercurial repository setup with a few named branches. I want to
I want to make a program that moves certain named folders (and all files
I have a folder named Comics and sub folders in that directory with the

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.