相关疑难解决方法(0)

Shell Scripting不想要'?' 文件名末尾的字符

我得到了一个不想要的'?' 在执行此操作时,在我的文件名末尾:

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.如果回波打印正确,为什么会发生这种情况?如何删除尾随问号字符?

bash shell cp

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

bash ×1

cp ×1

shell ×1