小编Neu*_*ran的帖子

如何在bash数组的所有条目中用下划线替换空格

我正在尝试使用文件夹中的文件填充数组,但如果名称中有空格,则会将它们拆分并且数组中填充单个单词.这是我尝试用下划线替换空格的代码:

 array=($(ls)) | sed -r 's/ /_/g'
Run Code Online (Sandbox Code Playgroud)

如何将ls项记录到bash数组中?

unix arrays macos bash whitespace

2
推荐指数
1
解决办法
377
查看次数

标签 统计

arrays ×1

bash ×1

macos ×1

unix ×1

whitespace ×1