Find the answer to your Linux question:
Results 1 to 3 of 3
Hello, I need imbricated awk . As awk is not an awk command, I use system : awk ' $1=="[PATH]" { myPath=$2 print "Processing Directory " $2 } $1=="[FILE]" { ...
  1. #1
    Just Joined!
    Join Date
    Apr 2007
    Posts
    2

    How to perform imbricated awk ?

    Hello,

    I need imbricated awk. As awk is not an awk command, I use system :

    awk '
    $1=="[PATH]" {
    myPath=$2
    print "Processing Directory " $2
    }
    $1=="[FILE]" {
    print " Processing File " $2
    ficPrincipal=myPath $2
    ficCorrection=myPath $3
    ficBase=myPath "base_" $2
    ficTab=myPath "tab_" $2
    echo "" > ficBase;
    echo "" > ficTab;
    system(awk '
    BEGIN {flag=1}
    flag<=1 && $1=="FREQUENCY" {print $0 >> ficBase; flag=2}
    flag<=2 && $1!="1" {print $0 >> ficBase}
    flag==2 && $1=="1" || flag>=3 {flag=3; print $2 " " $3 >> ficTab}
    ' ficPrincipal)
    }
    ' listeGraph

    My script is not complete, but at this point, I already run in error :
    $ bash creeGraph
    awk: cmd. line:14: system(awk
    awk: cmd. line:14: ^ unexpected newline or end of string
    creeGraph: line 16: =1: No such file or directory
    creeGraph: line 17: =2: No such file or directory
    creeGraph: line 18: ==1: command not found
    creeGraph: line 18: flag: command not found
    creeGraph: line 21: )
    }
    : command not found

    Does somebody how to do it ?

  2. #2
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    Welcome to the forums.

    By imbricated (over-lapping), I assume you are referring to what we usually call nested, but not necessarily recursive.

    You appear to want to call awk from within an awk script.

    If this is so, then, in the script you posted, you will need to figure out the quoting problem. Single quote to single quote is causing the problem.

    So look into that, then post again if you are still having trouble. Please use the [CODE] blocks to help us see the code more clearly, for example:
    Code:
    system(awk '
    Best wishes ... cheers, drl

    PS Nice word, imbricated; I know a lot of English words, but I don't recall running across that one.
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  3. #3
    Just Joined!
    Join Date
    Apr 2007
    Posts
    2
    Hello drl and thank you for your answer ,

    Sorry for "imbricated". Actually, I have mean "nested", as you have noticed it.

    From your information, I have externalized inside awk processing into another file :

    Code:
    awk -- '
    	$1=="[PATH]" {
    		myPath=$2
    		print "Traitement du répertoire " $2
    	}
    	$1=="[FILE]" {
    		print "  Traitement du fichier " $2
    		ficPrincipal=myPath $2
    		ficCorrection=myPath $3
    		ficBase=myPath "base_" $2
    		ficTab=myPath "tab_" $2
    		echo "" > ficBase;
    		echo "" > ficTab;
    		system(awk -f traiteFic -- ficPrincipal)
    	}
    	' listeGraph
    There are other errors, but the nesting problem looks solved . I have to manage arguments passing to the inside awk now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...