linux - 在 linux 中从字符串中提取子字符串

标签 linux awk sed

我需要从 oracle-xe-11.2.0-1.0.x86_64.rpm.zip 中提取 oracle-xe-11.2.0-1.0.x86_64.rpm我不知道如何开始。

必须满足的条件只有.zip需要去掉。如果没有 .zip 则字符串不会发生任何变化。怎么办?

最佳答案

改用basename:

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

结果:

oracle-xe-11.2.0-1.0.x86_64.rpm

关于linux - 在 linux 中从字符串中提取子字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31761098/

相关文章:

python - 我如何将加载/保存功能合并到我用 python 编写的游戏中

regex - 从 ifconfig 解析接口(interface)

linux - sed:无效的范围结束

linux - 在 Buffallo NAS (Optware) 上自动启动 noip2

c - linux c : what's the common use case of "sched_setaffinity" function? 我觉得没用

c - 如何处理来自 Linux 内核模块中已经具有不可共享处理程序的 PCI 设备的中断?

linux - 脚本搜索多个字符串

linux - 如何在 Windows 中获取 CSV 文件中的可变列数?

windows - awk 和 WinGrep 中的正则表达式

regex - 在文本文件中按列对唯一元素进行排序