(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:host)
          op: assign_op.Equal
          rhs: {(DQ (intuitive.com))}
          spids: [10]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:maxmatches)
          op: assign_op.Equal
          rhs: {(20)}
          spids: [18]
        )
      ]
    )
    (command.ShAssignment
      pairs: [(assign_pair lhs:(sh_lhs_expr.Name name:count) op:assign_op.Equal rhs:{(0)} spids:[21])]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:temp)
          op: assign_op.Equal
          rhs: 
            {
              (DQ (/tmp/) 
                (command_sub
                  left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:27)
                  command_list: 
                    (command.CommandList
                      children: [(C {(basename)} {($ Id.VSub_Number '$0')})]
                    )
                ) (.) ($ Id.VSub_Dollar '$$')
              )
            }
          spids: [24]
        )
      ]
    )
    (C {(trap)} 
      {
        (DQ 
          (command_sub
            left_token: (Token id:Id.Left_Backtick val:'`' span_id:40)
            command_list: (command.CommandList children:[(C {(which)} {(rm)})])
          ) (' -f ') ($ Id.VSub_DollarName '$temp')
        )
      } {(0)}
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (C {(Id.Lit_LBracket '[')} {($ Id.VSub_Pound '$#')} {(-eq)} {(0)} {(Id.Lit_RBracket ']')})
              terminator: (Token id:Id.Op_Semi val:';' span_id:66)
            )
          ]
          action: [
            (command.Simple
              words: [
                {(echo)}
                {
                  (DQ ('Usage: ') 
                    (command_sub
                      left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:75)
                      command_list: 
                        (command.CommandList
                          children: [(C {(basename)} {($ Id.VSub_Number '$0')})]
                        )
                    ) (' logfile')
                  )
                }
              ]
              redirects: [
                (redir.Redir
                  op: (Token id:Id.Redir_GreatAnd val:'>&' span_id:83)
                  fd: -1
                  arg_word: {(2)}
                )
              ]
            )
            (command.ControlFlow
              token: (Token id:Id.ControlFlow_Exit val:exit span_id:88)
              arg_word: {(1)}
            )
          ]
          spids: [54 68]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (C {(Id.Lit_LBracket '[')} {(Id.KW_Bang '!')} {(-r)} {(DQ ($ Id.VSub_Number '$1'))} 
                  {(Id.Lit_RBracket ']')}
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:108)
            )
          ]
          action: [
            (command.Simple
              words: [
                {(echo)}
                {(DQ ("Error: can't open file ") ($ Id.VSub_Number '$1') (' for analysis.'))}
              ]
              redirects: [
                (redir.Redir
                  op: (Token id:Id.Redir_GreatAnd val:'>&' span_id:121)
                  fd: -1
                  arg_word: {(2)}
                )
              ]
            )
            (command.ControlFlow
              token: (Token id:Id.ControlFlow_Exit val:exit span_id:125)
              arg_word: {(1)}
            )
          ]
          spids: [94 110]
        )
      ]
    )
    (command.ForEach
      iter_name: URL
      iter_words: [
        {
          (command_sub
            left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:138)
            command_list: 
              (command.CommandList
                children: [
                  (command.Pipeline
                    children: [
                      (C {(awk)} 
                        {
                          (SQ 
                            (Token
                              id: Id.Lit_Chars
                              val: '{ if (length($11) > 4) { print $11 } }'
                              span_id: 142
                            )
                          )
                        } {(DQ ($ Id.VSub_Number '$1'))}
                      )
                      (C {(grep)} {(-vE)} 
                        {
                          (DQ ('(/www.') ($ Id.VSub_DollarName '$host') ('|/') 
                            ($ Id.VSub_DollarName '$host') (')')
                          )
                        }
                      )
                      (C {(grep)} {(SQ (Token id:Id.Lit_Chars val:'?' span_id:170))})
                    ]
                    negated: F
                  )
                ]
              )
          )
        }
      ]
      do_arg_iter: F
      body: 
        (command.DoGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:searchengine)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (DQ 
                        (command_sub
                          left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:179)
                          command_list: 
                            (command.CommandList
                              children: [
                                (command.Pipeline
                                  children: [
                                    (C {(echo)} {($ Id.VSub_DollarName '$URL')})
                                    (C {(cut)} {(-d/)} {(-f3)})
                                    (C {(rev)})
                                    (C {(cut)} {(-d.)} {(-f1-2)})
                                    (C {(rev)})
                                  ]
                                  negated: F
                                )
                              ]
                            )
                        )
                      )
                    }
                  spids: [177]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:args)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (DQ 
                        (command_sub
                          left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:213)
                          command_list: 
                            (command.CommandList
                              children: [
                                (command.Pipeline
                                  children: [
                                    (C {(echo)} {($ Id.VSub_DollarName '$URL')})
                                    (C {(cut)} 
                                      {(-d) 
                                        (word_part.EscapedLiteral
                                          token: (Token id:Id.Lit_EscapedChar val:'\\?' span_id:223)
                                        )
                                      } {(-f2)}
                                    )
                                    (C {(tr)} {(SQ (Token id:Id.Lit_Chars val:'&' span_id:232))} 
                                      {(SQ (Token id:Id.Lit_Chars val:'\\n' span_id:236))}
                                    )
                                    (C {(grep)} {(-E)} 
                                      {
                                        (SQ 
                                          (Token
                                            id: Id.Lit_Chars
                                            val: '(^q=|^sid=|^p=|query=|item=|ask=|name=|topic=)'
                                            span_id: 248
                                          )
                                        )
                                      }
                                    )
                                    (C {(sed)} {(-e)} 
                                      {(SQ (Token id:Id.Lit_Chars val:'s/+/ /g' span_id:260))} {(-e)} {(SQ (Token id:Id.Lit_Chars val:'s/%20/ /g' span_id:266))} {(-e)} 
                                      {(SQ (Token id:Id.Lit_Chars val:'s/"//g' span_id:272))}
                                    )
                                    (C {(cut)} {(-d) (Id.Lit_Equals '=')} {(-f2)})
                                  ]
                                  negated: F
                                )
                              ]
                            )
                        )
                      )
                    }
                  spids: [211]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {(Id.Lit_LBracket '[')} {(Id.KW_Bang '!')} {(-z)} 
                          {(DQ ($ Id.VSub_DollarName '$args'))} {(Id.Lit_RBracket ']')}
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:301)
                    )
                  ]
                  action: [
                    (command.Simple
                      words: [
                        {(echo)}
                        {
                          (DQ (${ Id.VSub_Name searchengine) (':      ') ($ Id.VSub_DollarName '$args'))
                        }
                      ]
                      redirects: [
                        (redir.Redir
                          op: (Token id:Id.Redir_DGreat val:'>>' span_id:316)
                          fd: -1
                          arg_word: {($ Id.VSub_DollarName '$temp')}
                        )
                      ]
                    )
                  ]
                  spids: [287 303]
                )
              ]
              else_action: [
                (command.Simple
                  words: [
                    {(echo)}
                    {
                      (DQ (${ Id.VSub_Name searchengine) ('       ') 
                        (command_sub
                          left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:335)
                          command_list: 
                            (command.CommandList
                              children: [
                                (command.Pipeline
                                  children: [
                                    (C {(echo)} {($ Id.VSub_DollarName '$URL')})
                                    (C {(cut)} 
                                      {(-d) 
                                        (word_part.EscapedLiteral
                                          token: (Token id:Id.Lit_EscapedChar val:'\\?' span_id:345)
                                        )
                                      } {(-f2)}
                                    )
                                  ]
                                  negated: F
                                )
                              ]
                            )
                        )
                      )
                    }
                  ]
                  redirects: [
                    (redir.Redir
                      op: (Token id:Id.Redir_DGreat val:'>>' span_id:351)
                      fd: -1
                      arg_word: {($ Id.VSub_DollarName '$temp')}
                    )
                  ]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:count)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (DQ 
                        (word_part.ArithSub
                          anode: 
                            (arith_expr.Binary
                              op_id: Id.Arith_Plus
                              left: (arith_expr.ArithWord w:{($ Id.VSub_DollarName '$count')})
                              right: (arith_expr.ArithWord w:{(Id.Lit_Digits 1)})
                            )
                        )
                      )
                    }
                  spids: [359]
                )
              ]
            )
          ]
        )
    )
    (C {(echo)} {(DQ ('Search engine referrer info extracted from ') (${ Id.VSub_Number 1) (':'))})
    (command.Pipeline
      children: [
        (C {(sort)} {($ Id.VSub_DollarName '$temp')})
        (C {(uniq)} {(-c)})
        (C {(sort)} {(-rn)})
        (C {(head)} {(-) ($ Id.VSub_DollarName '$maxmatches')})
        (C {(sed)} {(SQ (Token id:Id.Lit_Chars val:'s/^/  /g' span_id:415))})
      ]
      negated: F
    )
    (C {(echo)} {(DQ )})
    (C {(echo)} {(Scanned)} {($ Id.VSub_DollarName '$count')} {(entries)} {(Id.KW_In in)} {(log)} {(file)} 
      {(out)} {(of)} 
      {
        (command_sub
          left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:442)
          command_list: 
            (command.CommandList
              children: [
                (command.Simple
                  words: [{(wc)} {(-l)}]
                  redirects: [
                    (redir.Redir
                      op: (Token id:Id.Redir_Less val:'<' span_id:447)
                      fd: -1
                      arg_word: {(DQ ($ Id.VSub_Number '$1'))}
                    )
                  ]
                )
              ]
            )
        )
      } {(total.)}
    )
    (command.ControlFlow token:(Token id:Id.ControlFlow_Exit val:exit span_id:457) arg_word:{(0)})
  ]
)