OS:Yocto
I want to assign the shell output to a variable,
but get the error "test.sh: line 3: out: command not found".
How to do that ...?
this is my code:
#!/bin/bash
out = "$(ls /dev/ | grep "tty" | wc -l)"
echo"$out"
I tried this: How to set a variable to the output from a command in Bash?
Whitespace matters.
#!/bin/bash
out="$(ls /dev/ | grep "tty" | wc -l)"
echo "$out"
when you assign value to variable don't keep Whitespace before and after "=" that makes error in bash
#!/bin/bash
out="$(ls /dev/ | grep "tty" | wc -l)"
echo"$out"
尝试围绕=
条带空间,即out="$(ls /dev/ | grep "tty" | wc -l)"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.