Please refer to the steps below that would guide you in running Wordcount job using Pig.
Lets create a pig script first.
Command: gedit word_count_prog.pig
Add the below lines in it
lines = LOAD '/home/edureka/Desktop/word_input' AS (line:chararray);
words = FOREACH lines GENERATE FLATTEN(TOKENIZE(line)) as word;
grouped = GROUP words BY word;
wordcount = FOREACH grouped GENERATE group, COUNT(words);
DUMP wordcount;
Create a file word_input on the desktop of Edureka VM that contains few text lines.
Later run the pig script using the below command.
Command: pig -x local word_count_prog.pig
You may refer to below screenshot for the commands used and input file used.
Hope it helps you.