macos - .bashrc 文件意外结束

标签 macos bash osx-mavericks unexpectendoffile

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

操作系统: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

最佳答案

当您说 麻烦的行如下 时,您是对的。你少了一个分号。说:

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

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

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

关于macos - .bashrc 文件意外结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20311907/

相关文章:

macos - 在 Mac OS X 的预览应用程序中清除最近的项目..?

swift - MacOS:如何让 NSPanel 抵抗关键焦点(使用 becomesKeyOnlyIfNeeded?)

macos - 在 OSX 上规范化 bash 中的任意文件路径

bash - 此处文档 - 意外的文件结尾

bash - gnu-parallel:exec:perl:找不到

bash - 我可以将默认值分配给 bash 中的数组吗?

command-line - 在 Mavericks 上运行 find 和 sed 后 sed 出现 "invalid command code ."错误

macos - 代理人承认未能使用 key 进行签名。操作系统

xcode - 如何使用 swift 从包中加载 applescript 文件?

macos - 命令 systemctl 和 service 是否仅存在于 linux 上而不存在于 mac 上?