私はパラメータ$1
を持っています。例えば、文字列operations/software/tools-manifest
に設定されていて、それを文字列operations-software-tools-manifest
に変換したいのです。 e。すべてのスラッシュ(/
)をダッシュ(-
)に置き換えます。これはbash
だけで可能ですか?たとえばsed(1)
とは呼びませんか?
私は(unsucessfully)試してみました:
[[email protected] ~]$ testparam=operations/software/tools-manifest
[[email protected] ~]$ echo "${testparam////-/}"
operations-/software-/tools-manifest
[[email protected]assepartout ~]$ echo "${testparam///-/}"
operations/software/tools-manifest
[[email protected] ~]$ echo "${testparam//\//-/}"
operations-/software-/tools-manifest
[[email protected] ~]$ echo "${testparam//\\//-/}"
operations/software/tools-manifest
[[email protected] ~]$ echo "${testparam//[/]/-/}"
operations/software/tools-manifest
[[email protected] ~]$ echo "${testparam//\x2f/-/}"
operations/software/tools-manifest
[[email protected] ~]$ echo "${testparam//\57/-/}"
operations/software/tools-manifest
[[email protected] ~]$
* argl *なぜ私のテストで '/'の末尾を使用したのですか?ありがとう! –