What are some common HDFS commands that can be mapped in the bash files?

妖精的绣舞 提交于 2020-01-05 05:54:27

问题


I am relatively new to Hadoop and I have been using HDFS CLI a lot. Commands like hdfs dfs -ls are becoming redundant to type. Is it possible to create an alias to this command (i.e., h -ls) in either the .bashrc or .bash_profile files? Are there any other useful commands that I can map here?


回答1:


The good practice is to put aliases in .bash_aliases.

For your problem, I'd put alias h="hdfs dfs" in my .bash_aliases file (create it if it doesn't exist)

Most distribs will already have this in their .bashrc file but if it's not there, add

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

in your .bashrc

Now you can either type source .bashrc or restart you terminal and h -ls wille be interpreted as hdfs dfs -ls

Note that cou can also very well put all of your aliases directly in the .bashrc, but I find it more convenient to have all the aliases set appart.

Are there any other useful commands that I can map here?

Look at this, it might give you some ideas : https://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html

And you can add what you want so if you run a command really often you can consider adding it in your aliases.

Hope this helps!



来源:https://stackoverflow.com/questions/58415032/what-are-some-common-hdfs-commands-that-can-be-mapped-in-the-bash-files

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