Quantcast
Channel: Question and Answer » gawk
Viewing all articles
Browse latest Browse all 13

Escape sequences passed as args to gawk not interpreted

$
0
0

I want to be able to pass an argument on the command line to gawk that is evaluated for escape sequences.

The issue:

$ gawk 'BEGIN { print ARGV[1]; }' 't'
t

Instead, I would like to get an actual tab character.

From the gawk docs:

The escape sequences in the preceding list are always processed first, for both string constants and regexp constants. This happens very early, as soon as awk reads your program.

How can I interpret character escapes in the command line args?

The end goal is myscript.awk --sep 't', where separator is a format string, so passing a literal tab isn’t an option. I’m also familiar with the easy way I could perform this in bash, but I’m interested in a way to do this in [g]awk.


Viewing all articles
Browse latest Browse all 13

Trending Articles