小编Sea*_*ean的帖子

从ksh中的数组中删除特定值

我有一个我在ksh中使用的自定义.profile,下面是我创建的一个函数,可以从具有过于复杂或长名称的目录中来回跳过.

如您所见,路径名存储在数组(BOOKMARKS[])中以跟踪它们并在以后引用它们.我希望能够使用case语句(或必要时的OPTARG)从数组中删除某些值,这样我只需键入bmk -d #即可删除相关索引处的路径.

我已经摆弄了array +A and -A,但它刚刚搞砸了我的阵列(注释掉的代码中剩下的东西可能不太漂亮......我没有校对它).

有关如何创建该功能的任何建议/提示?谢谢!

# To bookmark the current directory you are in for easy navigation back and forth from multiple non-aliased directories
# Use like 'bmk' (sets the current directory to a bookmark number) to go back to this directory, i.e. type 'bmk 3' (for the 3rd)
# To find out what directories are linked to which numbers, type 'bmk -l' (lowercase L)
# For every new directory …
Run Code Online (Sandbox Code Playgroud)

arrays ksh function

6
推荐指数
1
解决办法
8483
查看次数

标签 统计

arrays ×1

function ×1

ksh ×1