Reputation: 415
I try to get the length of a string like this (bash in linux):
VAR= grep "test" file.txt
VARlength= ${#VAR}
For some reason the length is always zero, even if the string "test" is inside file.txt
Can someone explain me how to get the length of VAR and what is wrong there?
Upvotes: 0
Views: 293
Reputation: 195039
don't leave space before and after the =
you need command substitution: var=$(command)
Upvotes: 2