Use a cat + grep as an included source in bash
- by Andrew
I'm on a shared webhost where I don't have permission to edit the global bash configuration file at /ect/bashrc. Unfortunately there is one line in the global file, mesg y, which puts the terminal in tty mode and makes scp and similar commands unavailable. My local ~./bashrc includes the global file as a source, like so:
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
My current workaround uses cat and grep to output the global file, sans offending line, into a local file and use that as a source.
# Source global definitions
if [ -f /etc/bashrc ]; then
cat /etc/bashrc | grep -v mesg > ~/.bash_global
. ~/.bash_global
fi
Is there a way to do include a grokked file like this without the intermediate step of creating an actual file? Something like this?
. cat /etc/bashrc | grep -v mesg > ~/.bash_global