Posts

Showing posts from November 21, 2018

How to POSIX-ly count the number of lines in a string variable?

Image
up vote 10 down vote favorite 1 I know I can do this in Bash: wc -l <<< "${string_variable}" Basically, everything I found involved <<< Bash operator. But in POSIX shell, <<< is undefined, and I have been unable to find an alternative approach for hours. I am quite sure there is a simple solution to this, but unfortunately, I didn't find it so far. shell-script variable string posix share | improve this question asked 2 days ago Vlastimil 7,397 11 56 132 ...