Bash Shell Count Number of Characters In a String or Word


Reference : http://www.cyberciti.biz/faq/unix-linux-appleosx-bsd-bash-count-characters-variables/


1. Use the following syntax to count ‘s’ character in a variable called $x:
echo “$x” | grep -o “s” | wc -l

2. To match both ‘s’ and ‘S’, enter:
echo “$x” | grep -oi “s” | wc -l


WRITTEN BY
RootFriend
개인적으로... 나쁜 기억력에 도움되라고 만들게되었습니다.

,