linux bash tail path =带空格的变量

时间:2015-10-06 10:19:15

标签: string bash tail

尝试用尾巴来修复问题,在给尾部带有空格的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.

0 个答案:

没有答案