小编cat*_*ail的帖子

shell字符串坏替换

我知道这很愚蠢,但我是shell的新手,我真的不知道这里发生了什么.以下是打算在zip文件被提取后获取目录名.因此,如果有效,结果将是这样的

$test.sh helloworld.zip
helloworld
Run Code Online (Sandbox Code Playgroud)

我们来看看test.sh:

#! /bin/sh
length=echo `expr index "$1" .zip`
a=$1    
echo $(a:0:length}
Run Code Online (Sandbox Code Playgroud)

然而,我得到了糟糕的替代,这只是搞砸了.
当我提到'shell'时.我只是在谈论shell而我不知道bash或其他之间的差异.我只是使用ubuntu 10.04并使用终端.我想我正在使用bash.

string shell substitution

6
推荐指数
2
解决办法
3万
查看次数

标签 统计

shell ×1

string ×1

substitution ×1