gnu - Busybox 中是否缺少花括号支持?
问题描述
我在我的设备上使用 Busybox。当我尝试执行多目录删除时,Busybox 中包含的“rm”命令似乎忽略了我的花括号。有没有办法增加对它的支持?它破坏了一些包含大括号脚本的包,我不想在我自己的脚本中放置循环。
例子:
rm -rf /some/path/{foo,bar}
解决方案
这取决于您使用的外壳。Busybox 至少带有 2 个默认 shell:ash
并且hush
,根据您构建它的方式,您可能同时拥有这两个 shell。如果rm -rf /some/path/{foo,bar}
对您不起作用,您可能正在使用ash
. 您可以检查:
$ echo $0
ash
检查您是否有hush
:
$ busybox hush
花括号应该适用于hush
:
$ mkdir /tmp/curly-test
$ cd /tmp/curly-test
$ touch foo bar
$ cd /tmp
$ ls curly-test/{foo,bar}
curly-test/bar curly-test/foo
另请注意,作为最后的手段,您可以简单地替换/bin/sh
为bash
.
推荐阅读
- authentication - 我需要在没有中间件的情况下在 NestJS 中进行身份验证
- php - EC2 上带有管理员的 Bitnami - 如何增加 max_upload_size
- java - PreparedStatementCallback 动态查询参数
- node.js - 如何在 node.js 中链接页面
- php - 在 Laravel 控制器操作中为相关项目使用 UUID
- html - 需要帮助在我的图像旁边隐藏文本/标记/线条
- python - 如何使用 selenium webdriver 在 python 中单击或选择输入下拉框的第一个元素(值)
- python-3.x - 如何更改 Django REST 框架中 URL 中的默认搜索查询参数?
- python - 如何根据另一个数据框值突出显示数据框,以便可以将突出显示的数据框导出到excel
- python-3.x - Received ValueError: mmap length is greater than file size when using sklearn RandomizedSearchCV