小编Sup*_*oob的帖子

修改bash字符串

我是 bash 新手,需要帮助解决这个问题。

#!/bin/bash

str="This Is My Bash String"
mod="-val"

# Loop through characters of str. If index is 0, insert mod at position 0. And if the current index contains space (" "), then insert mod after the space.

echo -e str
# This should output: -valThis -valIs -valMy -valBash -valString
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

string bash

0
推荐指数
1
解决办法
59
查看次数

标签 统计

bash ×1

string ×1