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 -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -