From: Polak, Jon (Jon_Polak@icgcomm.com)
Date: Thu Oct 23 2003 - 17:22:54 EDT
to the ksh wizards...
I want to consolodate two ksh scripts into one but in this case I am not
sure if it is possible.
Any suggestions would be greatly appreciated.
The first script is the main one that does a find command to invoke the
second script on each matching entry.
###########
#!/bin/ksh
# this is script1.ksh
find /usr/xyz -name "file00*" -mtime +30 -exec script2.ksh {} \;
###########
#!/bin/ksh
# this is script2.ksh
LOGFILE=$1
grep -i "my data" $LOGFILE | awk '{ --------- long awk script here
---------}'
###########
Optimally I would like to define script2 as a function within the script1 as
in the following example.
###########
#!/bin/ksh
report_func () {
LOGFILE=$1
grep -i "my data" $LOGFILE| awk '{ --------- long awk script here
---------}'
}
find /usr/xyz -name "file00*" -mtime +30 -exec report_func {} \;
###########
Unfortunately the exec portion of the find command doesn't seem to have
visibility to the function, even if I export the function. Has anyone ever
found a way to script something like this using just one ksh script?
Thanks
Jon
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:27:21 EDT