下面的例子解释了这个问题。为什么FILENAME
在使用替换时回显并感知为模式时打印正确?
#!/bin/bash
FILEPATH_WITH_GLOB="/home/user/file_*"
FILENAME=$(basename "$FILEPATH_WITH_GLOB")
echo $FILENAME #file_1234
echo ${FILENAME:1:5} #ile_* <---why is this not ile_1
Run Code Online (Sandbox Code Playgroud)