Quote:
Originally Posted by
jazz8146
I thought i could do like a sed command that substitutes everything except letters to nothing leaving just the letters then save that to a file.
i.e
sed 's/[a-z]// file > numbers
If this is what you really want to do (see the points Yogesh and gus have raised) you can do that. In fact you have almost already done it, there is just a minor detail missing:
s/something/other/
will change
only the first occurrence of "something" in every line to "other". If you want to change any occurrence you have to use the "global"-operator:
s/something/other/
g
Hence your script would work this way:
sed 's/[a-z]//g' file > numbers
This will replace every (smallcap) character with "nothing", effectively deleting it. If you want to delete *every* character use: "[a-zA-Z]" or, better, "[^0-9.+-]". The "^" will invert the character mask, meaning "everything NOT mentioned here". The given expression will mean "everything, save for numbers 0-9, literal points *) and pluses and minuses **)".
So, your script should read:
sed 's/[^0-9.+-]//g' file > numbers
*) if you could have decimal numbers
**) if you could have signs
bakunin