[英]bash script assign output to a variable fail
OS:Yocto
我想將shell輸出分配給變量,
但得到錯誤“test.sh:第3行:out:命令未找到”。
怎么做 ...?
這是我的代碼:
#!/bin/bash
out = "$(ls /dev/ | grep "tty" | wc -l)"
echo"$out"
我試過這個: 如何在Bash中將命令的變量設置為輸出?
空白很重要。
#!/bin/bash
out="$(ls /dev/ | grep "tty" | wc -l)"
echo "$out"
當你為變量賦值時,不要在“=”之前和之后保留空格,這會在bash中產生錯誤
#!/bin/bash
out="$(ls /dev/ | grep "tty" | wc -l)"
echo"$out"
嘗試圍繞=
條帶空間,即out="$(ls /dev/ | grep "tty" | wc -l)"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.