Small shell script (read domains names from a text file and push them into command via a variable)

Posted on 2006-05-16
Last Modified: 2010-04-17
its like this i have a txt file with domains sorted like this :

they are almost 500 domains.

I want to run a command for each domain something like du -sh /mydomains/
so I guess it has to be something like that du -sh /mydomains/$domains/logfolder/

how can I make the script read all the domains from the list, and each time replace the variable $domains and run the command till the list is over?

Question by:MaRiOsGR
    LVL 65

    Accepted Solution

    something like this perhaps

    for i in `cat txtfile`
        du -s "/mydomains/$i/logfolder"

    LVL 2

    Author Comment

    works great thank you!
    LVL 65

    Expert Comment

    no worries, glad to have helped

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now