- Community Home
- >
- Servers and Operating Systems
- >
- Legacy
- >
- Operating System - Tru64 Unix
- >
- Re: need help with shell script for array and loop...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
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
Community
Resources
Forums
Blogs
- 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
тАО12-13-2004 08:36 AM
тАО12-13-2004 08:36 AM
need help with shell script for array and loop processing files
write the output to a .txt flat file in unix.
what I have thus far: (old script)
diff ${REPORT_DIR}_db_dy_${ORACLE_SID}_a.dat ${REPORT_DIR}_db_dy_${ORACLE_SID}_b.dat > diffs.txt
I want to take these about 100 of these files and make an array and process all 100 of them in a ksh loop to separate reports in flat files. Can anyone help me with how to do this in a ksh script? Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-13-2004 08:42 AM
тАО12-13-2004 08:42 AM
Re: need help with shell script for array and loop processing files
no need to use arrays for this.
#!/bin/ksh
rm diffs.txt
SIDLIST="SID1 SID2 ... SID100"
for SID in ${SIDLIST}
do
diff ${REPORT_DIR}_db_dy_${ORACLE_SID}_a.dat ${REPORT_DIR}_db_dy_${ORACLE_SID}_b.dat >> diffs.txt
done
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-13-2004 08:44 AM
тАО12-13-2004 08:44 AM
Re: need help with shell script for array and loop processing files
hit the button too early. That should have been
diff ${REPORT_DIR}_db_dy_${SID}_a.dat ${REPORT_DIR}_db_dy_${SID}_b.dat > diffs.txt
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-13-2004 08:52 AM
тАО12-13-2004 08:52 AM
Re: need help with shell script for array and loop processing files
example:
diff ${REPORT_DIR}r${YESTERDAY}_db_dy_${ORACLE_SID}_report1.dat
${REPORT_DIR}r${TODAY}_db_dy_${ORACLE_SID}_report2.dat
>${REPORT_DIR}r${TODAY}_db_dy_${ORACLE_SID}_diffs.dat
-- echo reports to files
echo "${ORACLE_SID} RESULTS FOR ${TODAY}">${REPORT_DIR}r${TODAY}_db_dy_${ORACLE_SID}_diffrepots.txt
As you can see when you have 100 of these diff files and need to echo them to a flat file the shell script gets very messy and confusing! I want to clean the logic up by using an array in a loop so that when a new batch of files are added I just add a new array member to the stack. Thank you very much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-13-2004 10:23 AM
тАО12-13-2004 10:23 AM
Re: need help with shell script for array and loop processing files
in case you did not notice, I was ruuning a for loop. I have only one diff.
But if you want an array, that is no problem.
You use arrays like
SIDLIST[0]="sid1"
They have one index, are created automatically and can hold up to 1023 members.
greetings,
Michael