gawk -d가 현재 작업 디렉토리에 awkvars.out을 생성하지 않는 이유는 무엇입니까?

gawk -d가 현재 작업 디렉토리에 awkvars.out을 생성하지 않는 이유는 무엇입니까?

gawk -d확실히내장awkvars.out내 현재 작업 디렉토리입니다. 왜? 대신 다음과 같은 표준 출력을 얻습니다.

Usage: gawk [POSIX or GNU style options] -f progfile [--] file ...
Usage: gawk [POSIX or GNU style options] [--] 'program' file ...
POSIX options:      GNU long options: (standard)
    -f progfile     --file=progfile
    -F fs           --field-separator=fs
    -v var=val      --assign=var=val
Short options:      GNU long options: (extensions)
    -b          --characters-as-bytes
    -c          --traditional
    -C          --copyright
    -d[file]        --dump-variables[=file]
    -D[file]        --debug[=file]
    -e 'program-text'   --source='program-text'
    -E file         --exec=file
    -g          --gen-pot
    -h          --help
    -i includefile      --include=includefile
    -l library      --load=library
    -L[fatal|invalid|no-ext]    --lint[=fatal|invalid|no-ext]
    -M          --bignum
    -N          --use-lc-numeric
    -n          --non-decimal-data
    -o[file]        --pretty-print[=file]
    -O          --optimize
    -p[file]        --profile[=file]
    -P          --posix
    -r          --re-interval
    -s          --no-optimize
    -S          --sandbox
    -t          --lint-old
    -V          --version

To report bugs, see node `Bugs' in `gawk.info'
which is section `Reporting Problems and Bugs' in the
printed version.  This same information may be found at
https://www.gnu.org/software/gawk/manual/html_node/Bugs.html.
PLEASE do NOT try to report bugs by posting in comp.lang.awk,
or by using a web forum such as Stack Overflow.

gawk is a pattern scanning and processing language.
By default it reads standard input and writes standard output.

Examples:
    gawk '{ sum += $1 }; END { print sum }' file
    gawk -F: '{ print $1 }' /etc/passwd


답변1

물론, 매뉴얼은 오해의 소지가 있거나 적어도 불분명합니다. 문제는 gawk에게 실행할 프로그램을 제공해야 한다는 것입니다. 적어도 의 경우에는 gawk빈 문자열을 전달하면 충분합니다.

$ gawk -d '' 
$ ls awkvars.out 
awkvars.out

다음 방법 중 하나를 사용하여 다른 파일 이름을 설정할 수 있습니다.

gawk -dfoo.vars '' 

또는

gawk --dump-variables=foo1.vars '' 

둘 다 생성됩니다 foo.vars.

관련 정보