首页 > 解决方案 > 如何在shell脚本中连接变量中包含空格的文件夹路径列表

问题描述

我正在使用 shell 脚本在 Mac 上列出 Firefox 配置文件的文件和文件夹。现在,我的代码将获取配置文件文件夹名称并将它们放在一个列表中,但它会在遇到空格时拆分列表中的项目。我似乎找不到连接整个文件夹路径的两个部分的方法。

例如,路径 /Users/username/Library/Application Support/Firefox/Profiles/ 最终将是 /Users/username/Library/Application Support/Firefox/Profiles/

这是我的代码:

firefoxProfiles=$(find "/Users/$userName/Library/Application Support/Firefox/Profiles" -name '*.default*' -type d)
for x in $firefoxProfiles; do
echo "$x"

标签: bashshell

解决方案


推荐阅读