Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Setting filename in BEGIN
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 9th March 01:34
mario domgörgen
External User
 
Posts: 1
Default Setting filename in BEGIN



Hello!

I try to process a hardcoded filename in my awk script, but is seems
to be harder to accomplish than i thougt first.

My minimal failing code example:

--

BEGIN {
ARGV[1]="filename"
}

{ print $0 }

--

Shouldn't awk read ARGV[1] after processing BEGIN to get the first
filename to work with?

Hope anybody can help me here.

Best regards,

Mario

--
Chaos reigns within.
Reflect, repent, and reboot.
Order shall return.
  Reply With Quote


  sponsored links


2 9th March 01:34
gazelle
External User
 
Posts: 1
Default Setting filename in BEGIN



You also need to update ARGC.
  Reply With Quote
3 9th March 01:34
mario domgörgen
External User
 
Posts: 1
Default Setting filename in BEGIN


Hello!


Like "ARGC=ARGC"?

When i put that statement in my BEGIN section, nothing changes, awk is
still waiting for input from STDIN.

Mario

--
Chaos reigns within.
Reflect, repent, and reboot.
Order shall return.
  Reply With Quote
4 9th March 01:34
chris f.a. johnson
External User
 
Posts: 1
Default Setting filename in BEGIN


ARGC = 2 ## i.e., one more than the number of files you put in the ARGV array --
Chris F.A. Johnson <http://cfaj.freeshell.org>
================================================== ================
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
<http://www.torfree.net/~chris/books/cfaj/ssr.html>
  Reply With Quote
5 9th March 01:34
ed morton
External User
 
Posts: 1
Default Setting filename in BEGIN


<snip>

No, like incrementing it:

BEGIN {
ARGV[ARGC++]="filename"
}

{ print $0 }

Right, because you didn't change it.

Ed.
  Reply With Quote
6 9th March 01:34
mario domgörgen
External User
 
Posts: 1
Default Setting filename in BEGIN


Doh! Right, that was it, thanks you!

Mario


--
Chaos reigns within.
Reflect, repent, and reboot.
Order shall return.
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666