从使用bash给定路径中删除不必要的斜杠 [英] Remove unnecessary slashes from a given path with bash

查看:268
本文介绍了从使用bash给定路径中删除不必要的斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能在一个给定的路径去掉不必要的斜线?

例如:

  P =/ foo的//////酒吧///你好/////世界

我想:

  P =/富/酒吧/你好/世界


解决方案

感谢您的回信。我知道路径工作正常。我只是想这光的原因。

我找到了另一种解决办法:回声$ P |替换//'''

How can I get rid of unnecessary slashes in a given path?

Example:

p="/foo//////bar///hello/////world"

I want:

p="/foo/bar/hello/world"

解决方案

Thanks for the replys. I know the path works fine. I just want this for optical reasons.

I found another solution: echo $p | replace '//' ''

这篇关于从使用bash给定路径中删除不必要的斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆