|
|
retrieve script name
Imagine a script script.awk with functions A, B, and C:
#!/usr/bin/awk -f
# script.awk -- just loading functions
function A(x) { return x }
function B(x) { return x*x }
function C(x) { return sqrt(x) }
# EOF
Now linking the script like
$ ln script.awk A
$ ln script.awk B
$ ln script.awk C
Would it be possible to retrieve the name of the script called within
AWK? I tried ARGV[0] but that gave me /usr/bin/awk.
So what I really want is the name of the script loaded with -f <script>.
The reason why I want this is to call the corresponding function within
the script, like in the action statement { print SCRIPTNAME($1) }. If it
were possible, the string SCRIPTNAME "(" $1 ")" would be needed to be
evaluated...
Any ideas?
|
|
0
|
|
|
|
Reply
|
Rufus
|
2/18/2006 8:16:03 AM |
|
"Rufus T. Firefly" <mb.atelier@web.de> writes:
> Would it be possible to retrieve the name of the script called within
> AWK? I tried ARGV[0] but that gave me /usr/bin/awk.
AFAIK, awk doesn't make available the name of the file passed with
-f. Your best bet is probably to call awk with a shell script, and
pass the name of the shell script to the awk program, e.g.
#!/bin/sh
awk -f script.awk "scriptname=${0##*/}"
Cheers,
- Joel
|
|
0
|
|
|
|
Reply
|
Joel
|
2/18/2006 10:13:50 AM
|
|
|
1 Replies
360 Views
(page loaded in 0.044 seconds)
Similiar Articles: retrieve script name - comp.lang.awkImagine a script script.awk with functions A, B, and C: #!/usr/bin/awk -f # script.awk -- just loading functions function A(x) { return x } function ... script on statistics on sun solaris sparc servers - comp.unix ...retrieve script name - comp.lang.awk script on statistics on sun solaris sparc servers - comp.unix ... Dear colleagues, I need an advice in order to find a freeware script ... identify brooklyn dodger font??? - comp.fontsHey, I am hoping someone here knows the name of the font used for the uniforms of the Brooklyn (now L.A.) Dodgers, you know, the script writing with t... About Clean up file script - comp.unix.shellretrieve script name - comp.lang.awk About Clean up file script - comp.unix.shell... pkzip -x *.zip -u ${YEAR}${MON}sate ??${MON}* ${MON}*.log find . -name ... Find and Replace script, util, etc... - comp.databases.filemaker ...retrieve script name - comp.lang.awk Find and Replace script, util, etc... - comp.databases.filemaker ... retrieve script name - comp.lang.awk Find and Replace script ... VBScript (.vbs) mode - comp.emacsretrieve script name - comp.lang.awk Find mode- scripts-multiple criteria - comp.databases.filemaker ... Example: contact1 ... How to Get the Script Name in VBS | eHow.com ... Awk Script with multiple condition... - comp.lang.awkProblem With Multiple Field Separators - comp.lang.awk retrieve script name - comp.lang.awk Awk Script with multiple condition... - comp.lang.awk Problem With Multiple ... Problem With Multiple Field Separators - comp.lang.awkAwk Script with multiple condition... - comp.lang.awk Problem With Multiple Field Separators - comp.lang.awk retrieve script name - comp.lang.awk Awk Script with multiple ... Read from all files in a directory with a MATLAB Script - comp ...Hello everyone, I have a MATLAB script that reads some data from a text file and ... list of the files you want to process or to determine, given a file name, whether ... String substitution in file names using shell script - comp.unix ...I am trying to change the name of all files within a directory and subdirectories having a particular string with another string . E.g 'a1ss.txt' to ... How to retrieve the script name inside Powershell? - Vista ForumsWelcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. PowerShell Quick Tip: How to retrieve the current line number and ...Home > PowerShell, PowerShell Quick Tip > PowerShell Quick Tip: How to retrieve the current line number and file name in your PowerShell script 7/23/2012 12:12:31 AM
|
|
|
|
|
|
|
|
|