我想处理包含单引号文件名的文本文件中的文件,例如
'new'$'\n''line'
'tab'$'\t''ulator'
手动处理此文件的复制和粘贴工作正常:
test -f 'tab'$'\t''ulator'
现在,使用 bash read 内置命令从文件中读取
while IFS="" read -r myfile; do
line=$myfile
...
done < text.txt
给出包含转义单引号的字符串,例如
'\''new'\''$'\''\n'\'''\''line'\'''
'\''tab'\''$'\''\t'\'''\''ulator'\'''
但是,在 bash 脚本中处理此文件名不起作用。
test -f "$myfile"
test -f ${myfile}
如何在 bash 中禁用 /undo 转义单引号和处理原始文件名?