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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AWK script name from within AWK script 1

Status
Not open for further replies.

vgersh99

Programmer
Jul 27, 2000
2,146
US
yo,<br><br>&nbsp;&nbsp;awk -f foo.awk textFile.txt<br><br>How do I determine [programmatically} from WITHIN &quot;foo.awk&quot; its own name [foo.awk].<br>ARGV/ARGC don't get populated with&nbsp;&nbsp;the &quot;-f&quot;<br>switch.<br><br>I do NOT want to &quot;hard wire&quot; the name of the script to vararable - the &quot;foo.awk&quot; file can be changed/copied, but the actual implementation should NOT.<br><br>All I want to do is to &quot;reconstruct&quot; the original awk invokation line.<br><br>Any bright ideas?<br><br>thanks<br>
 
Try using the system function:<br><br>awk '{system(!!:p)}'<br><br>This will print the last history command,<br>but does not execute it, which I believe<br>is what you wanted to capture.<br><br> <p>flogrr<br><a href=mailto:flogr@yahoo.com>flogr@yahoo.com</a><br><a href= > </a><br>
 
Hey,<br><br>&nbsp;&nbsp;this is fine - solves the problem for the csh-derived shells.<br>&nbsp;&nbsp;I can probably &quot;mimic&quot; the behavior for the &quot;ksh&quot;.<br><br>&nbsp;&nbsp;Any bright ideas as how to GENERALIZE this approach to<br>tackle a problem for the &quot;shell independent&quot; environment?<br><br>thanks for the help<br><br>vlad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top