Trying to understand Bash file setups/structure

倖福魔咒の 提交于 2019-12-24 19:04:19

问题


This is an extension of a previously asked question: What are some common HDFS commands that can be mapped in the bash files?

I notice that the .bashrc and .bash_profile that I was initially provided are slightly different that what you have provided. Is this OK or some kind of different pattern?

The files that were copied over when I started are as follows:

.bashrc
.bash_profile

.bashrc

source /etc/bashrc 

...and a lot of other folder mappings

.bash_profile

# .bash_profile
# Get the aliases and functions
#if [ -f ~/.bashrc ]; then
#       .    ~/.bashrc
#fi
source ~/.bashrc

I created the .bash-aliases file as you recommended.

.bash_aliases

alias h="hdfs dfs"

I have modified the .bashrc file as follows

.bashrc - Modified

source /etc/bashrc 

...and a lot of other folder mappings

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

回答1:


The .bashrc code will be executed each before a new shell is started. The code that is in there doesn't matter, as long as it is valid bash.

The other files (bash_aliases) are just here to separate the commands in different files.

This article explains it quite well: https://ss64.com/bash/syntax-bashrc.html

So to answer your question, it won't cause problems at all. All that matters is that the way it's done satisfies you.



来源:https://stackoverflow.com/questions/58416260/trying-to-understand-bash-file-setups-structure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!