我在 bash 中有一個名為 myVar 的變數,其值如下所示。
'./favicon.png' './inc/sendEmail.php' './index.html' './images/header-background.jpg'
注意:以上代碼是一個變數的值
我想通過從每個路徑中洗掉初始點來將其更改為以下字串
'/favicon.png' '/inc/sendEmail.php' '/index.html' '/images/header-background.jpg'
我無法弄清楚如何做到這一點。請幫忙。
uj5u.com熱心網友回復:
使用 bash 引數擴展?
#!/bin/bash
myVar="'./favicon.png' './inc/sendEmail.php' './index.html' './images/header-background.jpg'"
echo "${myVar//.\///}"
'/favicon.png' '/inc/sendEmail.php' '/index.html' '/images/header-background.jpg'
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/515340.html
標籤:重击壳
