Re: awk im script
Goran <xamiw@arcor.de> writes:
> Sowas funktioniert: awk '{print $1}' $file > /tmp/$$
>
> Aber wie funktioniert's wenn ich die Spalte flexibel ändern möchte?
> Denn...
>
> sowas funktioniert nicht: awk '{print \$$spaltenzah}' $file > /tmp/$$
>
> Wie ändere ich aus dem Script heraus die Spaltenzahl die awk
> verarbeitet?
Was für ein Skript? Du meinst wohl nicht das awk-Skript, sondern
irgendein anderes (Shell-)Skript, das awk aufruft?
Wie wärs damit?
|-v var=val
|--assign var=val
| Assign the value val to the variable var, before execution of
| the program begins. Such variable values are available to the
| BEGIN block of an AWK program.
Thomas
Reply to: