Grep only numbers, not the alphanumeric entries
4
votes
4
answers
46097
views
I have a list of values like:
1
2
3
4
Ak123
Ak23
Ak147
1Apple
2Apricot
3Mango
4Orange
I just want to execute a simple grep command to list me only the numbers. i.e.
1
, 2
, 3
and 4
.
I tried this command -
grep -Ein --color '^\s*[0-9]' test.txt
but it returns the alphanumeric also. Instead I tried omitting the character by this command:
grep -Ein --color '^\s*[0-9][^A-Z]' test.txt
but it gives 0 results.
Asked by Srinivasan Senthil
(41 rep)
Nov 29, 2018, 06:01 PM
Last activity: Jun 20, 2023, 09:22 PM
Last activity: Jun 20, 2023, 09:22 PM