尝试用尾巴来修复问题,在给尾部带有空格的var时,我不能避免错误。
#!/bin/bash
.
.
.
function load_data
{
path="/home/robert/folder with_spaces/my_file"
}
.
.
.
function read_from_file
{
load_data
readed_line="$(tail -n 1 $path)"
}
并收到错误
tail: cannot open ‘/home/robert/folder’ for reading: No such file or directory
tail: cannot open ‘with_spaces/my_file’ for reading: No such file or directory
尝试按$var+=$var1
添加字符串
修改后的变体:""
''
``
但仍然相同
bash -version
GNU bash, version 4.3.11(1)-release (i686-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.