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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With