Use a grepped file as an included source in bash

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-03-16T07:19:41Z Indexed on 2010/03/16 7:46 UTC
Read the original article Hit count: 304

Filed under:
|

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 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
    grep -v mesg /etc/bashrc > ~/.bash_global
    . ~/.bash_global
fi

Is there a way to do include a grepped file like this without the intermediate step of creating an actual file? Something like this?

. grep -v mesg /etc/bashrc > ~/.bash_global

© Stack Overflow or respective owner

Related posts about bash

Related posts about grep