每当我尝试将命令的结果复制到变量时,'>' 符号

'>' symbol whenever I try to copy results of a command to a variable

每当我尝试将命令输出保存到变量终端时,都会出现“>”符号。我试过了:

n=$(awk 'END{print NR}' 1.log')

和 还有

n="$(awk 'END{print NR}' 1.log')"

每次我必须使用 ctrl+c 中断执行

我做错了什么?

可能是一个简单的拼写错误,带有杂散 '

试试这个:

n=$(awk 'END{print NR}' 1.log)

> 是一个提示,表明 bash 正在等待您关闭(杂散的)' 并匹配 '。打印的确切值保存在 PS2 变量中。以下内容来自 bash 手册:

PS2 The value of this parameter is expanded as with PS1 and used as the secondary prompt string. The default is '> '.