Use grepped file as an included source in bash

I am on a shared web host where I do not have permission to edit the global bash configuration file in /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 the source, for example:

 # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi 

My current workaround uses grep to output a global file, without it, to a local file and use this 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 make, for example, a grepped file without the intermediate step of creating the actual file? Something like that?

 . grep -v mesg /etc/bashrc > ~/.bash_global 
+1
source share
4 answers

lose a cat, its useless

 source <(grep -v "mesg" /etc/bashrc) 

The syntax <() is called process substitution .

+5
source
 . <(grep -v mesg /etc/bashrc) 
+2
source

I suggest calling mesg n :)

+1
source

From memory, but something like

 grep -v mesg /etc/bashrc | eval 

gotta do the trick

Since I'm not sure that eval will read stdin, you may need to rephrase it to

 eval `grep -v mesg /etc/bashrc` 
0
source

Source: https://habr.com/ru/post/926335/


All Articles