bash - 如何在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"
解决方案
推荐阅读
- tensorflow - 在 Colab 上运行带有 GPU 的 GPT-2(或 GPT Neo)文本生成模型
- java - 为什么我的内置 Spring 类没有 Docstring?
- android - 如何在 Android 上保存来自 IP 摄像机的视频?
- elasticsearch - Logstash 聚合字段
- react-native - 深度链接 React Native 可选组件
- reactjs - How to passe value from dropdown made by semantic ui in react
- jsf - 自定义 p:radioButton 在表格中不起作用:未找到选择的 id
- c++ - 在模板类中使用 std::conditional 的问题
- c# - C#如何在树视图中映射来自外部项目的文件
- r - 查找忽略 NA 的列的差异。仅查找数字的差异