Sep 18, 2002 #1 jo90 Programmer Jun 19, 2002 30 GB Hi, I have a file containing several awk functions, such as; function1() { BEGIN { FS = "'" } print " " $2 } can anyone tell me if this is correct, or how to call this from within a ksh script...
Hi, I have a file containing several awk functions, such as; function1() { BEGIN { FS = "'" } print " " $2 } can anyone tell me if this is correct, or how to call this from within a ksh script...
Sep 18, 2002 1 #2 vgersh99 Programmer Jul 27, 2000 2,146 US #!/bin/ksh function1() { echo "${1}" | nawk -F "'" '{print " " $2}' } var="foo'bar'xyz" secondField=$(function1 "${var}" vlad +---------------------------+ |#include<disclaimer.h> | +---------------------------+ Upvote 0 Downvote
#!/bin/ksh function1() { echo "${1}" | nawk -F "'" '{print " " $2}' } var="foo'bar'xyz" secondField=$(function1 "${var}" vlad +---------------------------+ |#include<disclaimer.h> | +---------------------------+
Sep 18, 2002 Thread starter #3 jo90 Programmer Jun 19, 2002 30 GB Thanks vlad, Worked great. I can now source my file from script & call the function.... Upvote 0 Downvote
Sep 18, 2002 1 #4 olded Programmer Oct 27, 1998 1,065 US Jo90: In addition to sourcing a file, if you're using korn/bash, you can use the autoload feature. Place these lines in /etc/profile, .profile, etc. export FPATH=/usr/eds/functions # This is where autoloaded source resides autoload function1 # alias for typeset -fu Now, function1 isn't loaded until it's needed, and if you have a lot of other functions in the source file, they're never loaded unless required. Regards, Ed Upvote 0 Downvote
Jo90: In addition to sourcing a file, if you're using korn/bash, you can use the autoload feature. Place these lines in /etc/profile, .profile, etc. export FPATH=/usr/eds/functions # This is where autoloaded source resides autoload function1 # alias for typeset -fu Now, function1 isn't loaded until it's needed, and if you have a lot of other functions in the source file, they're never loaded unless required. Regards, Ed