Skip to content
Advertisement

Extract substring from string in linux

i need to extract oracle-xe-11.2.0-1.0.x86_64.rpm from oracle-xe-11.2.0-1.0.x86_64.rpm.zip and i have no clue how to start.

The condition that must be met is only .zip needs to be removed. If there is no .zip then nothing should happen to the string . How to go with it ?

Advertisement

Answer

Use basename instead:

basename oracle-xe-11.2.0-1.0.x86_64.rpm.zip .zip

Result:

oracle-xe-11.2.0-1.0.x86_64.rpm
Advertisement