Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

276
Vistas
AWK match working locally but not in bash on debian server

I have following strange issue. I'll try to extract a string from a textfile with awk, but it's not working on the bash at my server.

Textfile looks like (textfile.txt)

dummy text name="formtoken" value="bd54839c3348d1c6ed7ab2c266f8a50b" dummy text

And I want to fetch the formtoken value out of the file. My awk statement is:

awk '/formtoken/ {match($0,/name="formtoken" value="(.{32})"/,arr); print arr[1]}' < textfile.txt

Locally the commands result is "bd54839c3348d1c6ed7ab2c266f8a50b"

On the debian server (connected via ssh) I get "awk: line 1: syntax error at or near ,"

Maybe someone has a good hint for me :)

Thanks,

RCX

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Debian-based distributions use Mawk as the default awk, and your command doesn't work with Mawk.

It works with Gawk (GNU Awk), which is probably what you've installed locally.

The reason your command doesn't work with Mawk is that you're using the 3-parameter form of the match() function, which is Gawk extension; the function signatures are:

  • Gawk: match(s, r [, a])
  • Mawk (and BSD Awk, and POSIX): match(s, r)

Ed Morton, in a since cleaned-up comment, suggests using the following variation of the command, which should work with all Awks:

awk 'sub(/.*name="formtoken" value="/,""){ sub(/".*/,""); print}' textfile.txt
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda