3

我已经搜索并找到了几个答案,但我没有成功改变我的答案。

操作系统:Mac OS X

我的 .bashrc 内容

# Before other PATHs...
PATH=${PATH}:/usr/local/share/python

alias la='ls -la'

function find_cpp_filepath_with_string { find $1 -name "*.cpp" -type f -exec  grep -l $2 {} \;}

#export -f find_cpp_filepath_with_string

else
    echo "WARNING: Can't find virtualenvwrapper.sh"
fi

麻烦的线如下

function find_cpp_filepath_with_string { find $1 -name "*.cpp" -type f -exec  grep -l $2 {} \;}

尝试 source ~/.bashrc 后,结果是:

line 21: syntax error: unexpected end of file
4

1 回答 1

4

当你说的时候你是对的troublesome line is the following。你少了一个分号。说:

function find_cpp_filepath_with_string { find $1 -name "*.cpp" -type f -exec grep -l $2 {} \; ; }

                ^
                |-----  You need to add a semicolon here!

需要第一个分号来表示命令的-exec结束find在command group之后需要第二个。

于 2013-12-01T12:14:41.013 回答