Apache Pig Utility Commands

This post aims to let you know the shell and utility commands that help in various situations.

Shell Commands
(1) fs:

Any FsShell command can be called from a Pig script or the Grunt shell. These commands can be used to get a list of available files in HDFS, create directories, move data from one location to another, and so on.

Usage:
grunt> fs -mkdir /tmp
grunt> fs -copyFromLocal <FromFileLocation> <ToFileLocation>
grunt> fs -ls <FileLocation>
grunt> fs -ls

(2) sh:
Invokes any sh shell command from within a Pig script or the Grunt shell.

Usage:
grunt> sh ls
The above command will list out all the files and directories from the file system.

3) ls:
Unix command to list out the files and directories.

Usage:

grunt> ls
The above command lists out all the files and directories from the home directory.

4) clear:
To clear the screen of commands and output of the executions.

Usage:
grunt> clear

5) exec:
In order to execute Apache Pig’s script.

Usage:
grunt> exec <script-path>

6) help:
The help command prints a list of Pig commands or properties.

Usage:
grunt> pig -help

7) history:
This will return the history of the commands that were executed in Grunt’s shell.

Usage:
grunt> history

8) kill:
Use the kill command to kill a Pig job based on the job id.

Usage:
grunt> kill <jobId>

9) quit:
To exit from the grunt shell.

Usage:
grunt> quit
Or you can use keyboard shortcut- control+D

 

Hope you find it helpful.

Please join our mailing list to receive more interesting information.

One comment

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