[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to escape shell string in gawk?
From: |
Peng Yu |
Subject: |
How to escape shell string in gawk? |
Date: |
Sat, 16 May 2020 18:09:05 -0500 |
Hi,
I can not escape the shell string below. Is there a way to do so? Thanks.
$ tmpdir=$(mktemp -d)
$ echo a > "$tmpdir/a b.txt"
$ awk -v tmpfile="$tmpdir/a b.txt" -e 'BEGIN { "cat " tmpfile |
getline x; print x }'
cat: /tmp/mktemp/tmp.XjMDBFsh9R/a: No such file or directory
cat: b.txt: No such file or directory
$ awk -v tmpfile=$(builtin printf %q "$tmpdir/a b.txt") -e 'BEGIN {
"cat " tmpfile | getline x; print x }'
awk: cmd. line:1: b.txt
awk: cmd. line:1: ^ syntax error
--
Regards,
Peng
- How to escape shell string in gawk?,
Peng Yu <=