本文介绍了bash文件中可以映射哪些常见的HDFS命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Hadoop比较陌生,并且我经常使用HDFS CLI。 hdfs dfs -ls 之类的命令变得多余。是否可以在 .bashrc 或 h -ls ) code> .bash_profile 文件?我还能在这里映射其他有用的命令吗?

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?

推荐答案

好的做法是将别名放在 .bash_aliases 。

The good practice is to put aliases in .bash_aliases.

对于您的问题,我会输入 alias h = hdfs dfs .bash_aliases 文件中的c $ c>(如果不存在则创建它)

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

大多数分配在它们的 .bashrc 文件中已经有此文件,但如果不存在,请添加

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

在您的 .bashrc中

现在,您可以输入 source .bashrc 或重新启动终端并 h -ls 将被解释为 hdfs dfs -ls

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

cou还可以很好地将所有别名直接放在 .bashrc 中,但是我发现将所有别名设置为appart更为方便。

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.

看看这个,它可能会给您一些想法:

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.

希望这会有所帮助!

这篇关于bash文件中可以映射哪些常见的HDFS命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 05:16