bash - How to extract numbers and special characters in a string in linux script -


i have string basedir=/cp/osp/peaker/1543.23. here want extract 1543.23, in linux script, tell me how here.

may using sed, regex, unable do. here want 1543.23 (so want number , special character . also).

you use awk. like

echo $basedir | awk 'begin {fs="/"};{print $nf}' 

that begins setting field separator (fs) "/" , printing last field.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -