# ulimit: only what is safe to check everywhere. case $(ulimit) in unlimited | [0-9]*) echo "default is -f" ;; esac case $(ulimit -n) in [0-9]*) echo "-n is a number" ;; esac [ "$(ulimit -f)" = "$(ulimit)" ] && echo same (ulimit -n 32; ulimit -n) (ulimit -S -n 40; ulimit -S -n; ulimit -H -n | grep -c .) (ulimit -f 100; ulimit -f) ulimit -a | grep -c -- '-n)' ulimit -Z 2>/dev/null; echo "status=$?" ulimit -n abc 2>/dev/null; echo "status=$?" (ulimit -c 0; ulimit -c) # A limit whose byte count does not fit rlim_t is refused, not wrapped to # zero: 2^54 kbytes is 2^64 bytes, and it used to become a 0-byte stack. (ulimit -s 18014398509481984) 2>err; echo "status=$?" sed 's/^[^:]*: line [0-9]*: //' err