Executing Shell Commands in Apache Hive

One does not need to exit Hive or start a new shell to verify the files and directories of HDFS, copy files from the local system to HDFS, or list out the files from the home directory. Such HDFS commands can also be run in Hive.

This is accomplished by adding an exclamation point (!) before the shell command, as seen below.

hive> ! hadoop fs -ls;
The command above will allow you view the HDFS files and folders.

hive> ! ls;
The above command will display the contents of the home directory’s files and folders.

hive> ! hadoop fs -put Desktop/Docs/emp.csv /user/cloudera/empdir;
The command above will copy the file from the local file system to the HDFS destination.

Similar way, other HDFS commands can also be executed via Hive’s shell.

Hope you find this article helpful.

To receive quick updates, just enter your email address and click the “follow” button.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s