Please follow the below screenshots for creating pig script:
press i, for inserting data into the new file created. After which you can either paste or type the below pig commands in the script.
Now for saving the pig script, you need to press esc button and then type :wq and then press enter. This will store the pig script to your local file system i.e, on your FTP and not to the hdfs. For executing the pig script, you need to keep the script in local itself.
Now for executing the pig script, follow the below screenshots:
I hope this helps.