• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

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

its like this i have a txt file with domains sorted like this :

mydomain1.com
mydomain2.com
mydomain3.com

they are almost 500 domains.

I want to run a command for each domain something like du -sh /mydomains/mydomain1.com/logfolder/
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?

0
MaRiOsGR
Asked:
MaRiOsGR
  • 2
1 Solution
 
rockiroadsCommented:
something like this perhaps

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

0
 
MaRiOsGRAuthor Commented:
works great thank you!
0
 
rockiroadsCommented:
no worries, glad to have helped
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now