Bash awk更改脚本中的工作目录

Bash awk更改脚本中的工作目录,bash,unix,awk,system,pwd,Bash,Unix,Awk,System,Pwd,我想更改awk脚本中的工作目录: ... path="./some/path" system("pwd") ; \ current_dir=system("pwd") ; \ pushd_cmd="pushd " path ; \ # a "cd" doesn't work too print pushd_cmd ; \ system(pushd_cmd) ; \ system("pwd"); \ # the same direc

我想更改awk脚本中的工作目录:

  ...
  path="./some/path"
  system("pwd") ; \
  current_dir=system("pwd") ; \
  pushd_cmd="pushd " path ; \    # a "cd" doesn't work too
  print pushd_cmd ; \
  system(pushd_cmd) ; \
  system("pwd"); \               # the same directory as before
  type="xml"
  ls_cmd = "ls *." type;         # so I can't find the files. Specifying with "./some/path/*.xml" doesn't work too (without trying to change the working directory)
  ...

有人知道为什么系统在我的情况下不起作用吗?

系统将启动子进程,子进程不能更改其父进程的工作目录

快速的谷歌搜索将显示GNU AWK文档的以下部分:


这似乎意味着标准AWK没有更改工作目录的方法。(在GNU AWK中,您可以使用
chdir
执行此操作。)

系统将启动子进程,子进程不能更改其父进程的工作目录

快速的谷歌搜索将显示GNU AWK文档的以下部分:

这似乎意味着标准AWK没有更改工作目录的方法。(在GNUawk中,您可以使用
chdir
完成这项工作,如您所见。)