linux报错:bash: syntax error near unexpected token `(‘ --路径中有括号怎么处理?

问题现象:执行命令时路径中带有括号符号“()”

解决办法有两种:

1.使用转义字符,在‘()’前加上\

dos2unix xiaoluo\(610603\)xiaoluo/1234.txt

2.在路径前后加上双引号

dos2unix "xiaoluo(610603)xiaoluo/1234.txt"

 在c++中用流打开时,必须使用第一种方法:

ifstream infile;

infile.open(strSourcePath, ios::in);
    if (!infile.is_open()) {
        cout << "Failed to open file. " << strSourcePath;
            throw 1;
    }

此时,strSourcePath中的()前后必须加上\,否则文件打不开

猜你喜欢

转载自blog.csdn.net/weixin_44843859/article/details/110043466