我得到了一个不想要的'?' 在执行此操作时,在我的文件名末尾:
emplid=$(grep -a "Student ID" "$i".txt | sed 's/(Student ID: //g' | sed 's/)Tj//g' )
#gets emplid by doing a grep from some text file
echo "$emplid" #prints employee id correctly
cp "$i" "$emplid".pdf #getting an extra '?' character after emplid and before .pdf
Run Code Online (Sandbox Code Playgroud)
即不是得到像123456.pdf这样的文件名,而是得到123456?.pdf.如果回波打印正确,为什么会发生这种情况?如何删除尾随问号字符?