当我在 mac 上打开终端时,如何摆脱“-bash: ulimit: 打开文件”

How can I get rid of "-bash: ulimit: open files" when I open terminal on my mac

每次我打开一个新终端时,都会显示这些消息:

-bash: ulimit: open files: cannot modify limit: Invalid argument
-bash: ulimit: max user processes: cannot modify limit: Operation not permitted

我以前确实修改过ulimit,但是我忘了我做了什么。那么我该如何解决这个问题,请帮忙。谢谢

----更新----

我的主目录中没有 .profile 或 .bashrc。但是我有一个 ~/.bash_profile 和 /etc/bashrc。而 ~/.bash_profile 看起来像

export PS1="\[3[36m\]\u\[3[m\]@\[3[32m\]\h:\[3[33;1m\]\w\[3[m\]$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GF'
alias ll='ls -GFl'

export JAVA_HOME=$(/usr/libexec/java_home)
export LC_CTYPE="en_US.UTF-8"

/etc/bashrc 看起来像:

# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
   return
fi

PS1='\h:\W \u$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
# Tell the terminal about the working directory at each prompt.
if [ "$TERM_PROGRAM" == "Apple_Terminal" ] && [ -z "$INSIDE_EMACS" ]; then
    update_terminal_cwd() {
        # Identify the directory using a "file:" scheme URL,
        # including the host name to disambiguate local vs.
        # remote connections. Percent-escape spaces.
    local SEARCH=' '
    local REPLACE='%20'
    local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
    printf '\e]7;%s\a' "$PWD_URL"
    }
    PROMPT_COMMAND="update_terminal_cwd; $PROMPT_COMMAND"
fi

我没有看到任何关于 ulimit 的信息。

----更新----

sudo ulimit -a -H
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) unlimited
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 65532
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1064
virtual memory          (kbytes, -v) unlimited

sudo ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 4864
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 709
virtual memory          (kbytes, -v) unlimited

我终于解决了这个问题。我发现打开新终端时 OS X 会加载 3 个配置文件,它们是“/etc/bashrc”、“/etc/profile”、“~/.[=17” =]”。我在“/etc/profile”的底部找到了 2 行关于 ulimit 配置的内容。我删除了这两行并解决了这个问题。

无论如何,感谢@Jonathan Leffler,你提醒我找出导致此问题的其他配置文件。谢谢 XD