Is there any wildcard character for awk FS? -
is there wildcard character awk fs? in awk script, can’t print values “^r” separators (i don’t know type of character this). on other hand, can print fs=”*” , others. below,
awk 'begin {fs="*"; i=0; ors=""} can’t awk 'begin {fs="^r"; i=0; ors=""} would appreciate help.
^r octal 022 or hex 12. ascii dc2 (device command 2) character.
octalin awk, utilize \022 match ^r field separator:
$ echo $'one\022two\022three' onetwothree $ echo $'one\022two\022three' | awk 'begin {fs="\022"; i=0; ors=""} {printf "1=%s; 2=%s; 3=%s\n",$1,$2,$3}' 1=one; 2=two; 3=three regular expression it possible utilize regular expressions field separators. in regular expressions, opposed shell globs, period wildcard:
$ echo $'one\022two\022three' | awk -f'.t' '{printf "1=%s; 2=%s; 3=%s\n",$1,$2,$3}' 1=one; 2=wo; 3=hree here, period (wildcard) in .t happens match ^r.
awk supports hex notation:
$ echo $'one\022two\022three' | awk -c -f'\x12' '{printf "1=%s; 2=%s; 3=%s\n",$1,$2,$3}' 1=one; 2=two; 3=three awk
No comments:
Post a Comment