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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:53:04+00:00 2026-06-05T13:53:04+00:00

i am inside a directory called TestJ. Inside this directory i have many folders

  • 0

i am inside a directory called TestJ. Inside this directory i have many folders like MSC1,MSC2 … MSC19, HLR1,HLR2 .. ,SGSN1,SGSN2 .. .Now inside each of these directories is a script ALARMS.sh. What i want to do is loop through all these folders and execute ALARMS.sh in each folder . what my present code does is use this

ls -d SGSN* > temp.txt
while read sgsn_line;do
    echo $sgsn_line
    cd $sgsn_line
    ALARMS.sh
    cd ..
done < temp.txt

ls -d HLR* > temp.txt
while read hlr_line;do
    echo $hlr_line
    cd $hlr_line
    ALARMS.sh
    cd ..
done < temp.txt

ls -d MSC* > temp.txt
while read msc_line;do
    echo $msc_line
    cd $msc_line
    ALARMS.sh
    cd ..
done < temp.txt
rm temp.txt 

But i want to do the same job without listing the folders in any file. like for example we can loop through files in a given folder using for file in *.txt. I would like to be able to do the same for folders(only folders).

  • 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-05T13:53:06+00:00Added an answer on June 5, 2026 at 1:53 pm

    Use like below…

    for sgsn_line in `ls -ltr SGSN* | grep ^d | awk '{print $NF}'`;do
        echo $sgsn_line
        cd $sgsn_line
        ALARMS.sh
        cd ..
    done
    
    ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one main directory called Forfun . Inside this directory, there are 7-8
I have a directory called cron, inside my app directory. In the cron directory,
I have this code that shows all the images inside 'images' directory but it
We simply have to move every page inside of a directory called Music to
I installed Celery (latest stable version.) I have a directory called /home/myuser/fable/jobs . Inside
I have made a directory called middle and inside it another directory called tier
I've got a directory called fb and a script inside called like.php. I'd like
CentOS 5.3 I have a directory called repos. Inside that directory I have repositories
I have an html deep inside my directory structure inside c:\ . one line
I would like to store files in a specific directory inside the documents directory,

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.