我正在尝试捕获命令替换的输出。这将一直有效,直到将管道添加到命令中为止。我做错了什么还是这是 mingw 的怪癖?
$ bash --version
GNU bash, version 4.3.46(2)-release (x86_64-pc-msys)
$ echo $(ls | wc -l)
23
$ test=$(ls | wc -l); echo test="$test"
test=
答案1
这看起来像是 mingw 的一个怪癖:
$ test=$(ls | wc -l); echo test="$test"
test=45
$ bash --version
GNU bash, version 4.3.43(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.