- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to write script for entering into 1 or mor...
Operating System - HP-UX
1752810
Members
6254
Online
108789
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2008 07:23 PM
тАО08-12-2008 07:23 PM
how to write script for entering into 1 or more dir and execute one script.
hi
for ex. i have 1 or more directories.I want to go inside every directory and i want to execute one script.
How to write the script for the above cases?
for ex. i have 1 or more directories.I want to go inside every directory and i want to execute one script.
How to write the script for the above cases?
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2008 07:50 PM
тАО08-12-2008 07:50 PM
Re: how to write script for entering into 1 or more dir and execute one script.
Hi Yogesh,
It is very easy, like if you have one directory "XYZ" under your /tmp and under XYZ you have six directory A,B,C,D,E,F. and you want to switch one by one in all directory and want to execute a script, then you need to follow below steps.
cd /tmp/XYZ/
ls | while read line
do
cd $line
sh <script name>
cd ..
done
Tell me if any thing other you want. . .
Regards,
Piyush Mathiya
It is very easy, like if you have one directory "XYZ" under your /tmp and under XYZ you have six directory A,B,C,D,E,F. and you want to switch one by one in all directory and want to execute a script, then you need to follow below steps.
cd /tmp/XYZ/
ls | while read line
do
cd $line
sh <script name>
cd ..
done
Tell me if any thing other you want. . .
Regards,
Piyush Mathiya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2008 11:10 PM
тАО08-12-2008 11:10 PM
Re: how to write script for entering into 1 or more dir and execute one script.
Hi,
for i in `find /tmp/test/* -type d`
do
echo $i
cd $i
/tmp/scriptname
done
- echo $i would show the dir name
-/tmp/scriptname is the script with executable permission or replace it with sh scriptname as in Piyush's post.
for i in `find /tmp/test/* -type d`
do
echo $i
cd $i
/tmp/scriptname
done
- echo $i would show the dir name
-/tmp/scriptname is the script with executable permission or replace it with sh scriptname as in Piyush's post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2008 11:14 PM
тАО08-12-2008 11:14 PM
Re: how to write script for entering into 1 or more dir and execute one script.
Or else you can first create text file contains all the dirs you want as below and manually modify as per your needs by adding more or deleting unwanted ones:
find /tmp/test/* -type d > /tmp/dirlist
Once you satisfied with the list of dirs then you can run the script on that file
for i in `cat /tmp/dirlist `
do
echo $i
cd $i
/tmp/scriptname
done
find /tmp/test/* -type d > /tmp/dirlist
Once you satisfied with the list of dirs then you can run the script on that file
for i in `cat /tmp/dirlist `
do
echo $i
cd $i
/tmp/scriptname
done
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP