sed to keep only numbers from the list
from this sample list of data i want to exract numbers only using sed in linux
9898922479 '19897774506' 9896460144 "9896300029" 98924645271 9858392130 9852150122 ss 9802108399sac 9802088710txt ss
into output like this format
9898922479 9897774506 9896460144 9896300029 9858392130 9852150122
Tagged:
0
Answers
-
#replace LF; with CR;LF; Carriage Return (Line Feed / CRLF) unix2dos file.txt #create new line at the end if missing echo \ >> file.txt #this will remove all the single and double quotes sed -i 's/[\"'\''\ ]//g' file.txt #this will remove all lines which do not match criteria (number starting with 1 and of 11 digits or 10 digit number not starting with 1) sed -i -E '/^1?[^1][0-9]{9}\s$/!d' file.txt #any spaces, tabs in lines sed -i '/^[[:space:]]*$/d' file.txt #replacing 1 in first postion with blank sed -i 's/^1//' file.txt
0
Howdy, Stranger!
Categories
- 94 All Categories
- 20 VoIP
- 7 SIP
- 16 asterisk
- 44 Programming
- 1 Nodejs
- 4 javascript
- 19 PHP
- 8 Codeigniter
- 14 database
- 1 UI/UX
- 2 Flutter
- 28 OS
- 26 Linux
- 1 Virtualization
- 1 Android
- 1 Windows
- 2 legal