Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I parse out each path from this variable? 1

Status
Not open for further replies.
Dec 12, 2007
19
US
If I have a variable with the values shown below, how do I parse out each path from this variable? The variable will have any where from 1 to n paths. I need to parse through and change directories to each path and perform some work. I know how to do the work but not how to parse this information out of this variable. Thanks in advance. Mark

Path="/dbawork/logarchmeth1/edwr02/EDWR02/NODE0000/C0000000
/dbawork/logarchmeth1/edwr02/EDWR02/NODE0001/C0000000
/dbawork/logarchmeth1/edwr02/EDWR02/NODE0002/C0000000
/dbawork/logarchmeth1/edwr02/EDWR02/NODE0003/C0000000
/dbawork/logarchmeth1/edwr02/EDWR02/NODE0004/C0000000
/dbawork/logarchmeth2/edwr02/EDWR02/NODE0000/C0000000
/dbawork/logarchmeth2/edwr02/EDWR02/NODE0001/C0000000
/dbawork/logarchmeth2/edwr02/EDWR02/NODE0002/C0000000
/dbawork/logarchmeth2/edwr02/EDWR02/NODE0003/C0000000
/dbawork/logarchmeth2/edwr02/EDWR02/NODE0004/C0000000"
 
Code:
#!/bin/ksh

Path="/dbawork/logarchmeth1/edwr02/EDWR02/NODE0000/C0000000 
/dbawork/logarchmeth1/edwr02/EDWR02/NODE0001/C0000000 
/dbawork/logarchmeth1/edwr02/EDWR02/NODE0002/C0000000 
/dbawork/logarchmeth1/edwr02/EDWR02/NODE0003/C0000000 
/dbawork/logarchmeth1/edwr02/EDWR02/NODE0004/C0000000 
/dbawork/logarchmeth2/edwr02/EDWR02/NODE0000/C0000000 
/dbawork/logarchmeth2/edwr02/EDWR02/NODE0001/C0000000 
/dbawork/logarchmeth2/edwr02/EDWR02/NODE0002/C0000000 
/dbawork/logarchmeth2/edwr02/EDWR02/NODE0003/C0000000 
/dbawork/logarchmeth2/edwr02/EDWR02/NODE0004/C0000000"

for dir in ${Path}
do
   echo "dir->[${dir}]"
done

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top