Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
操作字符串时,bash 中的百分号是什么意思?例如,是什么${0%/*}意思?
${0%/*}
如果您使用@fedorqui 的资源,您会看到它将/*从第一个位置参数的末尾剥离最短匹配。一个例子:
/*
example_foo(){ echo ${1%/*} } example_foo path/to/directory/sub_directory # => path/to/directory
在示例中,我使用了第二个位置参数,因为第一个是函数的名称。