How to enter two commands in pig gruntshell without typing enter key?

335 views Asked by At
A = LOAD '/pig/student.tsv' as (rollno:int, name:chararray, gpa:float);
DUMP A;

If I want to execute the first line, I have to type Enter key after the first line.

How can I make it as a single execution?

3

There are 3 answers

0
Kumar On BEST ANSWER

You can create a pig script file to make it as single execution.

test.pig

A = LOAD '/pig/student.tsv' as (rollno:int, name:chararray, gpa:float); 
DUMP A;

Now run the pig script using below command from pig/bin,

pig -f /path/test.pig
0
Sumit On

You need to create a pig script(say, myscript.pig) containing those 2 lines. Then, run this script using the command pig myscript.pig

0
thisdotnull On

Short-answer, use a script as suggested by Kumar.

Long answer, if you create a single line script containing multiple statements, then it will be not be long before it becomes a nightmare to read and understand as your script grows. Having said that, if you use a script, it won't matter whether you use one line or multiple lines.

So, my suggestion will be to use a well-indented script for learning/development/what-have-you.