The grep command-line utility found on Unix, Linux, and OS X systems can be used to extract strings from files or other data input to the command. As an example of extracting digits from a string, suppose I have the following text that contains a version number between
<string>
and </string>
:
<string>14.6.0</string>
I only want to see the 14.6.0
, so I can use the grep
command with the -o
option to specify I ony want the text
that matches a specified pattern displayed. The pattern I can use is
'[0-9.]\+
'.
[ More Info ]