Belajar Shell: Extract Digits From a String
How do I extract digits only from a given string under Bash shell? You can use the sed, grep and other shell utilities as follows: [sourcecode language=”bash”] grep -o "[0-9]" <<<"input" grep -o "[0-9]" <<<"$var" grep -o "[0-9]" <<<"test123" grep -o "[0-9]" <<<"1Th5is is a test. 5" var="foo1bar2" output=$(grep -o "[0-9]" <<<"$var") echo "$output" grep …