shell脚本字符串删除_如何从Shell脚本中的字符串中删除或获取尾数?

shell脚本字符串删除

How to delete or get the number in the tail from a string in shell script (bash script)? Okay to call other tools.

如何从shell脚本(bash脚本)的字符串中删除或获取尾部的数字? 可以调用其他工具 。

For example, from “/dev/sda8”, I want to get “/dev/sda” and “8” separately.

例如,我要从“ / dev / sda8”分别获得“ / dev / sda”和“ 8”。

This can be achieved by using sed as follows.

可以通过如下使用sed来实现。

To get the string after deleting the tailing numbers, we can use sed to replace the tailing numbers with an empty string.

要在删除尾号后获得字符串,我们可以使用sed将尾号替换为空字符串。

str=sda8

# get the string with th

你可能感兴趣的:(字符串,shell,python,linux,bash)