0

下面是我的代码片段,我正在尝试输出一个文件名以在两端都有双引号。

#!/usr/bin/ksh
.......
##the value is: Site Information_2013-07-05-00-01-26.CSV
RemoteFile=$(grep "$File" "$TempLog")


 ##then Im trying to redirect it to a file so that it will have double quotes 
 echo "\"$RemoteFile\"" > cmd

 ##I'm expecting below output.
"Site Information_2013-07-05-00-01-26.CSV"

##instead, the double quote is missing at the end, can someone point out what I'm doing wrong 

"Site Information_2013-07-05-00-01-26.CSV

谢谢。

4

1 回答 1

0

TempLog 包含以回车符结尾的行。2个解决方案

dos2unix "$TempLog"
sed -i 's/\r$//' "$TempLog"

末尾缺少双引号,因为在“V”之后有一个回车符,将“光标”移回行首。然后打印引号,覆盖第一个字符(也恰好是引号)。

于 2013-07-05T15:13:50.580 回答