- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Processing directory structures
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
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
тАО08-01-2006 09:35 AM
тАО08-01-2006 09:35 AM
Processing directory structures
admin/sql
admin/bin
admin/SID
admin/SID/adump
admin/SID/bdump
admin/log
archive
archive/SID
archive/SID/dmp
I want to process (actually build a "cp -R" command) for those entries that do not contain SID or those that contain SID but only as the last word. I don't want to process the entries that contain SID but have something after it (e.g. - SID/dmp).
My current code is attached. I'm not sure how to check for the last condition of something after SID.
I would imagine there is also probably a better way of handling the from and to directories so that I don't have to use 2 variables.
Thanks in advance for your help.
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2006 09:43 AM
тАО08-01-2006 09:43 AM
Re: Processing directory structures
Nice name.
Your code crashes my browser so I can't look.
basename
That will isolate the last variable and can be used to extract it into another variabel.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Tags:
- basename
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2006 09:48 AM
тАО08-01-2006 09:48 AM
Re: Processing directory structures
#!/bin/ksh
ORACLE_SID=${ORACLE_SID:-\wiltst1} #Default ORACLE_SID
SCRIPT_DIR=${SCRIPT_DIR:-\/oracle} #Default directory for scripts
FromDirNames=`find ${SCRIPT_DIR}/OB -type d | tail +2 | sed 's,'${SCRIPT_DIR}'/OB/,,'`
ToDirNames=`echo ${FromDirNames} | sed 's,SID,'${ORACLE_SID}',g'`
echo "\n\nFromDirNames=${FromDirNames}\n"
echo "\n\nToDirNames=${ToDirNames}\n"
for subdir in ${ToDirNames}
do
if [ -d "${ORACLE_BASE}/$subdir" ] ; then
echo "${ORACLE_BASE}/$subdir already exists"
else
echo "Creating ${ORACLE_BASE}/$subdir"
Cmd="cp -R ${SCRIPT_DIR}/OB/$subdir ${ORACLE_BASE}/$subdir"
FinalCmd="`echo ${Cmd} | sed 's/'${ORACLE_SID}'/SID/1'`"
echo "\t Cmd=${Cmd}"
echo "\t FinalCmd=${FinalCmd}"
fi
done # for subdir loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2006 09:53 AM
тАО08-01-2006 09:53 AM
Re: Processing directory structures
find ${SCRIPT_DIR}/OB -type d | grep -v SID$
this should eliminate tje lines ending with "SID" from the find output.
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2006 10:16 AM
тАО08-01-2006 10:16 AM
Re: Processing directory structures
Given that you have a variable loaded with (space-delimited) directories, like:
# echo ${VAR}
admin/sql admin/bin admin/SID admin/SID/adump admin/SID/bdump admin/log archive
archive/SID archive/SID/dmp
# echo ${VAR}|perl -nle '@a=split / /;for (@a) {print if m%/SID\z%;print unless m%SID%}'
...will yield:
admin/sql
admin/bin
admin/SID
admin/log
archive
archive/SID
...You could capture this output too:
# NEWVAR=`echo ${VAR}|perl -nle '@a=split / /;for (@a) {print if m%/SID\z%;print unless m%SID%}'`
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2006 11:06 AM
тАО08-01-2006 11:06 AM
Re: Processing directory structures
change...
FromDirNames=`find ${SCRIPT_DIR}/OB -type d | tail +2 | sed 's,'${SCRIPT_DIR}'/OB/,,'`
to...
FromDirNames=`find ${SCRIPT_DIR}/OB ! -path "${SCRIPT_DIR}/OB/*/SID/*" -type d | tail +2 | sed 's,'${SCRIPT_DIR}'/OB/,,'`
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-04-2006 04:43 AM
тАО08-04-2006 04:43 AM
Re: Processing directory structures
What I'm working on is a deployment script that needs to run on any environment. Right now I just need to worry about Sun, AIX and HP-UX. Any concerns with Perl compatibility?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-04-2006 04:54 AM
тАО08-04-2006 04:54 AM
Re: Processing directory structures
ANY environment - you are really aiming high :-)
But the UNIXs you mentioned
- as long as only such one liners are in play, they can be adopted to ANY perl-version
- as long as these OSs are in play, recent perl distributions of the same perl version are found at
http://activestate.com
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-04-2006 08:49 AM
тАО08-04-2006 08:49 AM
Re: Processing directory structures
Sandman, your syntax is not working for me:
"-path is not a valid option". Is that not supported on AIX?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-04-2006 08:59 AM
тАО08-04-2006 08:59 AM
Re: Processing directory structures
No, the '-path' switch is not valid with AIX's 'find'. If you want easy portability, you want Perl.
Using Perl, you could leverage the 'File::Find' core module if you want.
Regards!
...JRF...
- Tags:
- Perl